Repository navigation
fix: pause Instructor callbacks when agent hooks are disabled - #327
Merged
Merged
Conversation
Eigenwise
approved these changes
Oct 24, 2026
Eigenwise
left a comment
Owner
There was a problem hiding this comment.
Rechecked 26789a0. All seven native hook tests pass locally. Independent offline probes also checked real Instructor dispatch, shared-client callback ownership, and preservation of the observability hooks. Pause, resume, registration, removal, and clearing behave as intended. Exact-head CI is green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AtomicAgent.disable_hooks()setshooks_enabledto false, but callbacks registered on the Instructor client still run for subsequent completions. This also affects hooks registered while the agent is disabled. Detach this agent's callbacks while disabled and restore its remaining registrations on enable, with repeated enable/disable calls remaining idempotent.The regression tests use the real Instructor hook dispatcher and cover pause/resume, registration while disabled, removal/clearing while disabled, and preservation of callbacks registered directly on the client. A separate offline reproduction also exercised
AtomicAgent.run()through real Instructor/OpenAI clients and an HTTPX mock transport: two requests invoked the callback twice before the fix and once after it.Validation on Windows, Python 3.13.9, upstream
2a26bbc039fe29f3cdcf79eabc087b12d3fb9399:python -m pytest atomic-agents/tests/agents -q: 103 passed, 3 skipped.python -m pytest --cov=atomic_agents atomic-agents -q: 811 passed, 3 skipped, with 10 warnings (an unregistered integration marker and MCP transport deprecations).python -m black --check atomic-agents atomic-assembler atomic-examples atomic-forge: 233 files unchanged.python -m flake8 --extend-exclude=.venv atomic-agents atomic-assembler atomic-examples atomic-forge: passed.atomic-agents/tests/agents/test_config_defaults_typing.py, with the task environment's Python selected explicitly: 0 errors, 0 warnings, 0 informations. It also printed that the checkout has no.venvdirectory; the test environment lives separately.git diff --check: passed.Dependencies were installed into an isolated environment using the declared runtime/test ranges;
PYTHONPATHselected this checkout's source. Live provider calls, documentation builds, wheel-install tests, Linux/Python 3.12 checks and GitHub CI were not run locally. No manifest or lockfile changes.AI assistance: Codex investigated, authored and locally validated this change under LJK-ikun's direction. Independent human review or testing is not asserted.