fix(runtime): refresh fallback policy before turn start - #272
Merged
OmarB97 merged 1 commit intoJul 13, 2026
Conversation
Signed-off-by: Omar B <omar@kostudios.io>
OmarB97
added a commit
that referenced
this pull request
Jul 20, 2026
Signed-off-by: Omar B <omar@kostudios.io> Co-authored-by: Omar B <omar@kostudios.io>
13 tasks
OmarB97
added a commit
that referenced
this pull request
Aug 2, 2026
…#291) 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: Omar Baradei <omar@kostudios.io> 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.
Summary
Refresh cached desktop/TUI fallback policy inside the active profile context and publish
session.infobeforemessage.startor any model request.Live evidence
The installed desktop profile was changed from
fallback_policy: anytolocal-onlywhile its cached agent remained alive. The next turn enforced the refreshed policy insiderun_conversation, but the desktop footer still displayedFallback anythroughout the request, leaving operator telemetry unable to prove that cloud substitution was blocked.Change
Verification
scripts/run_tests.sh tests/run_agent/test_provider_fallback.py tests/tui_gateway/test_turn_outcomes.py tests/tui_gateway/test_fallback_policy_refresh.py -q— 59 passedsession.info, thenmessage.start, then requestpy_compile, andgit diff --checkpassRisk and rollback
The preflight performs one additional read-only config refresh per desktop/TUI turn and emits one extra session snapshot. Revert 58dcc02 to restore the prior event order.