Conversation
|
Duplicate of #16346 — same bug where fallback provider activation ignores explicit |
76b22e1 to
cc6eff9
Compare
|
Thanks — agreed this is the same underlying bug as #16346. I refreshed this PR to incorporate the useful coverage from #16346 while keeping it aligned with the current code layout:
Local validation: python -m py_compile agent/chat_completion_helpers.py tests/agent/test_fallback_api_mode.py
python -m pytest tests/agent/test_fallback_api_mode.py tests/run_agent/test_provider_fallback.py tests/run_agent/test_compressor_fallback_update.py -q -o 'addopts='
# 28 passedI could also close this in favor of #16346 if maintainers prefer that one, but #16346 currently targets the older |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused regression coverage. The reported defect remains present on current main: try_activate_fallback() reads fallback base URL/key at agent/chat_completion_helpers.py:1428-1444, but never reads fb["api_mode"]; it then forces codex_responses for a direct OpenAI fallback at agent/chat_completion_helpers.py:1483-1484.
Problems
- The PR is based on an older version of this helper. Current main added
base_url_hostname(fb_base_url) == "api.anthropic.com"to the Anthropic fallback condition atagent/chat_completion_helpers.py:1470in18c61bb8c. Since this PR is currently dirty, accepting its older replacement conditional during salvage would lose that fix.
Suggested changes
- Port the override gate around the current inference chain, preserving the current native-Anthropic-host check.
- Keep the existing compressor propagation already present at
agent/chat_completion_helpers.py:1629-1635(dcbcdd652), rather than duplicating that hunk.
Automated hermes-sweeper review.
| and base_url_host_matches(fb_base_url, "amazonaws.com") | ||
| ): | ||
| fb_api_mode = "bedrock_converse" | ||
| if not fb_api_mode_hint: |
There was a problem hiding this comment.
During salvage, retain current main's additional or base_url_hostname(fb_base_url) == "api.anthropic.com" clause in this branch (agent/chat_completion_helpers.py:1470, 18c61bb8c); accepting this stale conditional unchanged would reintroduce the native-Anthropic fallback misrouting fix.
Summary
fallback_providers[*].api_modebefore applying fallback provider/base-url heuristicsapi_modeis configuredWhy
When the primary agent runs via Codex/Responses and falls back to a plain OpenAI-compatible chat model, the current fallback activation path re-infers
api_modefromhttps://api.openai.com/v1and forcescodex_responses. That can send Responses-only encrypted reasoning/include metadata to chat-only fallback models and fail with:An explicit fallback entry such as:
should remain on
chat_completionseven if the primary runtime wascodex_responses.Tests
python -m pytest tests/agent/test_fallback_api_mode.py tests/run_agent/test_run_agent_codex_responses.py -q -o 'addopts='Related: #23450