Repository navigation
feat(setup): native /model picker via gateway model discovery - #17
Merged
Merged
Conversation
Set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 so Claude Code populates /model from our /anthropic/v1/models and the user can switch models natively. ANTHROPIC_MODEL[1m] stays the 1M default and does NOT lock the picker. Reset clears the key. Needs Claude Code >=2.1.129; picker lists claude* ids (Codex via /setup-codex). Co-Authored-By: Claude <noreply@anthropic.com>
wangcansunking
added a commit
that referenced
this pull request
Jul 3, 2026
#52) (#54) * fix(context-edit): dynamic whole-body budget + reactive 413 retry (issue #52 follow-up) Issue #52: the 413 returns when a screenshot-heavy session ALSO carries a large conversation. The 413 is on the WHOLE request body, but context editing budgeted only image bytes against a fixed 3.5MB cap — so a ~700k-token transcript (~2.7MB text) + 3 kept screenshots (~3.15MB) still exceeded the 5 MiB gateway wall. Fix 1 — dynamic budget: the image allowance is now GATEWAY_ENTITY_LIMIT (5 MiB) − SAFETY_MARGIN − nonImageBytes, capped by the fixed budget for the common small-text case. Big text auto-clears more screenshots. Verified on issue #52's exact 9 images: 343k text -> keep 3 (4.46MB), 500k -> keep 2, 700k -> keep 1 (3.79MB), 900k -> keep 0 — always under the wall. Fix 2 — reactive fallback: if the gateway STILL 413s, force-clear every screenshot and retry once instead of relaying a 502. Streaming retries on the first-pull 413 (before any content_block is written); non-stream wraps complete(). Tests: dynamic budget across text sizes, forceClearAllScreenshots, is413Error, end-to-end reactive-retry through the Express app (stream + non-stream), http-e2e big-text-fits-5MiB. 604 unit green; docker http-e2e ALL PASSED (68); tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(cli-e2e): case #17 sized to a valid <1M-token turn (issue #52 dynamic budget) The live CLI can't simultaneously hit the 5 MiB byte wall AND stay a valid <1M-token request: base64 images tokenize at ~char/4, so a ~5 MiB body is ~1.3M tokens, over the model window. The byte-budget math is therefore asserted hermetically (http-e2e, quota-free) and case #16 stresses a big screenshot pile on its own. Case #17 proves the live consequence: a substantial mixed conversation (~100k tokens prose + a screenshot pile) is a valid turn — no 413, newest screenshot still read. Sized to ~591k tokens after edit, comfortably under the 1M window. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <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
/modelwas unresponsive ("Kept model as…") because we pin ANTHROPIC_MODEL, which locks the picker. Fix: enable Claude Code's gateway discovery so the picker is fed by our /anthropic/v1/models and the user can switch natively.Caveats (Claude Code limits, not ours)
Test plan
🤖 Generated with Claude Code