fix: drop incompatible model slugs on auxiliary client cache hit#5804
Closed
eddieran wants to merge 1 commit into
Closed
fix: drop incompatible model slugs on auxiliary client cache hit#5804eddieran wants to merge 1 commit into
eddieran wants to merge 1 commit into
Conversation
This was referenced Apr 7, 2026
`resolve_provider_client()` already drops OpenRouter-format model slugs (containing "/") when the resolved provider is not OpenRouter (line 1097). However, `_get_cached_client()` returns `model or cached_default` directly on cache hits, bypassing this check entirely. When the main provider is openai-codex, the auto-detection chain (Step 1 of `_resolve_auto`) caches a CodexAuxiliaryClient. Subsequent auxiliary calls for different tasks (e.g. compression with `summary_model: google/gemini-3-flash-preview`) hit the cache and pass the OpenRouter- format model slug straight to the Codex Responses API, which does not understand it and returns an empty `response.output`. This causes two user-visible failures: - "Invalid API response shape" (empty output after 3 retries) - "Context length exceeded, cannot compress further" (compression itself fails through the same path) Add `_compat_model()` helper that mirrors the "/" check from `resolve_provider_client()` and call it on the cache-hit return path.
17fbec8 to
2700df7
Compare
kshitijk4poor
approved these changes
Apr 11, 2026
kshitijk4poor
left a comment
Collaborator
There was a problem hiding this comment.
Tests pass (96/96), reviewed — correctly adds _compat_model() guard on cache-hit paths. Fixes #5809.
9 tasks
Contributor
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
Fixes #5809
_get_cached_client()bypasses the model slug compatibility check inresolve_provider_client()on cache hits, allowing OpenRouter-format model slugs (e.g.google/gemini-3-flash-preview) to reach non-OpenRouter providers.The bug
resolve_provider_client()has a guard (line ~1097) that drops model slugs containing/when the resolved provider is not OpenRouter:But
_get_cached_client()returnsmodel or cached_defaulton cache hits (lines 1665/1667) without ever callingresolve_provider_client(), so this guard is skipped.Example: When
provider=openai-codex, the first auxiliary call caches aCodexAuxiliaryClientunder key("auto", ...). A subsequent compression call withmodel="google/gemini-3-flash-preview"(fromconfig.yamlcompression.summary_model) hits the cache and passes the slug to the Codex API, which doesn't understand it.Fix
Add
_compat_model()helper that mirrors the/-check fromresolve_provider_client(), called on both sync and async cache-hit return paths. When the cached client is not OpenRouter, model slugs containing/are dropped in favor of the cached default.Testing
tests/agent/test_auxiliary_client.pytests/test_crossloop_client_cache.py