test(agent): update stub agents for per-turn fallback-policy plumbing - #291
Merged
Conversation
PRs #269 and #272 added fallback-policy plumbing to the shared turn prologue (`_refresh_fallback_policy`, `_emit_pending_fallback_notice`) and structured status emission to the fallback activation path (`_emit_fallback_status`, which reads `self.status_callback` directly). Three test files build agents that deliberately bypass `__init__` — either `AIAgent.__new__(AIAgent)` or a hand-rolled `_FakeAgent` — and were never updated with the new attributes, so they raise AttributeError as soon as the prologue or fallback path runs. This is test-side only: `agent_init.py` sets `status_callback` unconditionally during real construction, so no shipped code path is affected. In `test_compressor_fallback_update.py` the breakage was masked: the missing `status_callback` raised inside `try_activate_fallback`, whose `except` swallowed it, logged "Failed to activate fallback", and recursed through the rest of the chain before failing on the terminal status emit. Stubs match the convention already used by tests/agent/test_turn_context.py. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
What does this PR do?
Fixes 11 tests that fail on
mainat collection/run time withAttributeError.PRs #269 and #272 added fallback-policy plumbing to the shared turn prologue
(
agent/turn_context.pynow calls_refresh_fallback_policy()and_emit_pending_fallback_notice()) and structured status emission to thefallback activation path (
_emit_fallback_status, which readsself.status_callbackdirectly).Three test files build agents that deliberately bypass
__init__— eitherAIAgent.__new__(AIAgent)or a hand-rolled_FakeAgent— and were neverupdated with the new attributes, so they raise
AttributeErroras soon as theprologue or the fallback path runs.
This is test-side only.
agent/agent_init.pysetsstatus_callbackunconditionally during real construction (in a plain sequential
callback-assignment block, with nothing emitting before it), so no shipped code
path is affected. Verified by reading the init ordering, not just by the tests
going green.
One detail worth flagging for review: in
test_compressor_fallback_update.pythe breakage was masked. The missing
status_callbackraised insidetry_activate_fallback, whose blanketexcept Exceptionswallowed it, loggedFailed to activate fallback gpt-4o, and then recursed through the remainder ofthe fallback chain before finally failing on the terminal status emit. A status
emission failure being able to walk the whole fallback chain is arguably its own
robustness issue — I have not changed that behavior here, since it is out of
scope for a test fix, but it may deserve a follow-up.
Related Issue
No filed issue — these surfaced once #286 unblocked
uv sync --lockedand thePython test slices ran for the first time since 2026-07-10.
Type of Change
Changes Made
tests/run_agent/test_compressor_fallback_update.py— setagent.status_callback = Noneon the__new__-built stub, with a comment explaining the masking behavior above.tests/agent/test_gateway_turn_sidecar.py— add_refresh_fallback_policy()/_emit_pending_fallback_notice()to_FakeAgent.tests/agent/test_api_content_sidecar.py— same two stubs on its_FakeAgent.Stub shapes match the convention already used by the maintained sibling
tests/agent/test_turn_context.py(which stubs exactly these three methods).How to Test
Per-file runs — single-process multi-file pytest cross-contaminates in this repo:
Before:
2 failed/4 failed, 4 passed/5 failed, 28 passed.After:
2 passed/8 passed/33 passed.HERMES_HOME. The suite reads the developer's real~/.hermes/config.yaml; a localfallback_policy: 'off'makes 5 unrelatedtests in
tests/test_tui_gateway_server.py::TestResolveRuntimeWithFallbackfaillocally that pass on CI (CI has no user config, so the policy defaults to
any). That is a pre-existing test-isolation gap, not something this PRchanges.
Checklist
Code
Documentation & Housekeeping
cli-config.yaml.example— N/ACONTRIBUTING.mdorAGENTS.md— N/A