Strip the [1m] context-window suffix before routing (companion to #8)#10
Merged
Merged
Conversation
Companion to OnlyTerp#8. That PR makes the launchers append a "[1m]" suffix to 1M-capable Claude model ids so Claude Code sizes its context meter (and auto-compaction) to the 1M window. The suffix is a client-side convention -- the 1M window itself is carried by the context-1m beta header -- not an Anthropic model id. The proxy looks up routes (and orchestrator/worker picks) by exact id, so once a pick carries "[1m]" a configured route like "claude-opus" no longer matches "claude-opus[1m]" and routing falls through / breaks. This strips a trailing "[1m]" from the request model id up front, so "<id>[1m]" behaves exactly like "<id>" everywhere downstream. The 1M window is unaffected (the beta header is left untouched), and the strip is universal so stock-traffic remap and the Auto Router stay consistent too. Depends on OnlyTerp#8: with OnlyTerp#8 not merged nothing emits the suffix, so this is a no-op on its own and only earns its keep once OnlyTerp#8 lands. Includes a unit test. Co-Authored-By: Claude Opus 4.8 <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.
Depends on #8
This is a companion to #8 and only earns its keep once that lands. Please review/merge #8 first — with #8 not merged, nothing emits the
[1m]suffix, so this change is a harmless no-op on its own.Why
#8 makes the launchers append a
[1m]suffix to 1M-capable Claude model ids so Claude Code sizes its/contextmeter and auto-compaction to the 1M window. The suffix is a client-side convention — the 1M window itself is carried by thecontext-1mbeta header — it is not an Anthropic model id.The proxy resolves routes (and orchestrator/worker picks) by exact id match. So once a pick carries
[1m], a configured route likeclaude-opusno longer matches the incomingclaude-opus[1m], and the request falls through / misroutes. This matters for any Anthropic-passthrough route to a 1M-capable Claude model (the recommended pattern when you want real Opus as a distinct orchestrator/worker pick under a non-claude-opus-4-8id).What
Strip a trailing
[1m]from the request model id at the very top oftransform_messages_body, so<id>[1m]behaves exactly like<id>everywhere downstream (tier classification, orchestrator/worker selection, route lookup, upstream forwarding).context-1mbeta header, which is left untouched.<id>[1m]→<id>), so stock-traffic remap and the Auto Router stay consistent too.scripts/doctor.pypass.🤖 Generated with Claude Code