fix: preserve conversation context when provider fallback activates#13235
Open
rfpassos wants to merge 1 commit intoNousResearch:mainfrom
Open
fix: preserve conversation context when provider fallback activates#13235rfpassos wants to merge 1 commit intoNousResearch:mainfrom
rfpassos wants to merge 1 commit intoNousResearch:mainfrom
Conversation
- rebuild api_messages inside each retry attempt - prevent provider-specific payload transforms from leaking into fallback - add regression tests for codex/chat and prompt-cache fallback cases - make fallback model tests self-contained
Collaborator
|
Likely duplicate of PR #13654 — same root cause: fallback reuses provider-specific payload instead of rebuilding from canonical conversation state. |
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
api_messageson every retry attempt instead of reusing a payload prepared for the previous providerRoot cause
When the primary model failed, Hermes switched
provider/model/api_modein-place, but continued using anapi_messagespayload that had already been prepared for the previous backend.That meant fallback requests could inherit backend-specific payload mutations such as:
cache_controlwrappersIn practice this could look like context loss or broken continuity after fallback, because the new backend was not receiving a fresh request built from the canonical conversation state.
Fix
AIAgent._build_api_messages_for_attempt(...)/steerpre-API drain, cache layout selection, tool-argument repair)Tests
Added regression coverage in:
tests/run_agent/test_fallback_context_preservation.pyValidated with:
pytest tests/run_agent/test_fallback_context_preservation.py -qpytest tests/run_agent/test_fallback_model.py -qpytest tests/run_agent/test_run_agent_codex_responses.py -qWhy this matters
Fallback should always start from the canonical conversation history, not from a payload already transformed for a different provider. This keeps tool state, prompt context, and conversation continuity intact when Hermes has to fail over mid-turn.