Skip to content

feat(setup): native /model picker via gateway model discovery - #17

Merged
wangcansunking merged 1 commit into
masterfrom
worktree-model-discovery
Jun 29, 2026
Merged

wangcansunking merged 1 commit into
masterfrom
worktree-model-discovery

Conversation

@wangcansunking

Copy link
Copy Markdown
Owner

Summary

  • /model was 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.
  • ANTHROPIC_MODEL[1m] stays the 1M default — verified vs docs that it does NOT lock the picker when discovery is on. 1M + switchable, as requested.
  • Reset clears the new key.

Caveats (Claude Code limits, not ours)

  • Needs Claude Code ≥2.1.129; older builds ignore the flag (no harm).
  • Picker lists claude* ids only — Codex/gpt via /setup-codex.
  • A switched model loses [1m] (drops to 200K); the default keeps 1M.
  • Version label still "Opus 4" — upstream family map, unfixable our side.

Test plan

  • setup.test asserts discovery flag; 422 pass, e2e 43, build clean

🤖 Generated with Claude Code

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
wangcansunking merged commit 14bc8ae into master Jun 29, 2026
5 checks passed
@wangcansunking
wangcansunking deleted the worktree-model-discovery branch June 29, 2026 06:02
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant