Skip to content

refactor(model-limits): plain model id, uniform 90% trigger - #259

Merged
quickbeard merged 2 commits into
mainfrom
limits-uniform-trigger
Aug 27, 2026
Merged

quickbeard merged 2 commits into
mainfrom
limits-uniform-trigger

Conversation

@quickbeard

@quickbeard quickbeard commented Aug 27, 2026 •

Copy link
Copy Markdown
Owner

What

Two changes to src/lib/model-limits.ts, matching quickbeard/codev-code#337 so the hub and CoDev Code's own configure flows keep writing the same numbers:

  1. The M3 model's id is a plain string — M3_ID = atob(...) is gone; the table keys on "MiniMax/MiniMax-M3" directly.
  2. The trigger is no longer a per-entry fixed number — TABLE now carries only context windows (Record<string, number>), and the trigger is always 90% of the window (COMPACT_PCT = 90, replacing DEFAULT_COMPACT_PCT = 80) whatever the window's source: the table, the 200K default, or a gateway-reported window via limitsFromWindow. Cached model_limits entries in auth.json keep whatever trigger they were stored with.

MiniMax-M3's table window is 262,144 — the current deployment serves it with that cap (resource limit), not the model's native 1M.

Effective numbers

Model Window (was → now) 90% trigger
MiniMax/MiniMax-M3 1,000,000 → 262,144 235,930
zai-org/GLM-4.7-cc / default 200,000 180,000

Per agent:

  • OpenCode/CoDev Code: both served models' 90% target + the shared 40,000 reserve exceeds their window, so declaredInput's existing clamp pins limit.input at the window itself — M3 262,144 (effective trigger 222,144), 200K-class 200,000 (effective 160,000). Never past the ceiling.
  • Codex: model_auto_compact_token_limit = 235,930 for M3, 180,000 for 200K-class (written directly, no clamp).
  • Claude Code: unchanged — 262,144 is still above Claude's 200K ceiling, so the window pin and the 80% cap behave exactly as before.
  • Continue: contextLength 262,144 for M3.

Tests

pnpm test (1431 passed), pnpm typecheck, pnpm check all clean. Updated expectations in model-limits.test.ts, configure.test.ts (OpenCode input math, Codex pins, Continue contextLength), and ModelSelect.test.tsx (window→limits conversion at 90%).

🤖 Generated with Claude Code

Quickbeard and others added 2 commits August 27, 2026 11:12
The table now carries only context windows — the trigger is always 90% of
the window regardless of source (table, default, or gateway-reported) —
and the 1M model's id is a plain string instead of base64.

Effective changes: the 1M model's compaction target moves from 800K to
900K (OpenCode limit.input 940000, Codex auto_compact_token_limit 900000);
200K-class models trigger at 180000 for Codex, while their OpenCode
declared input stays clamped at the window (effective 160000) and Claude
Code stays at its 80% ceiling.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The gateway serves MiniMax-M3 with a 262144-token window (resource cap),
not the model's native 1M. Trigger at 90% is 235930; for OpenCode the
target + 40000 reserve exceeds the window, so declaredInput's clamp pins
limit.input at the window (effective trigger 222144). Codex takes 235930
directly; Claude Code stays at its 200K ceiling.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@quickbeard
quickbeard merged commit 937b437 into main Aug 27, 2026
2 of 4 checks passed
@quickbeard
quickbeard deleted the limits-uniform-trigger branch August 27, 2026 04:24
quickbeard added a commit that referenced this pull request Sep 10, 2026
…262)

* feat(model-limits): give GLM-5.3-Flash its served 262144 window

The gateway serves zai-org/GLM-5.3-Flash with the same 262144-token window
as MiniMax-M3 (a deployment resource cap, not the model's native window),
but with no table entry it fell back to the safe 200K default — so every
agent CoDev configures for it was told the wrong window.

One table entry covers every command: install, config, model, and the
launch-time key refresh all write through the four configure.ts writers,
and each resolves its numbers from limitsFor.

Also refreshes the AGENTS.md section that still described the pre-#259
model-limits shape (explicit per-model triggers, an atob-encoded M3_ID,
DEFAULT_LIMITS at 200K/160K) and notes that the table has a twin in
codev-code that has to move with it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* feat(model-limits): drop the GLM-4.7-cc window entry

Its 200000 restated DEFAULT_WINDOW exactly, so limitsFor returns the same
{context: 200000, trigger: 180000} through the default tier and all four
writers emit identical config. The table now carries only the models whose
window differs from the default.

Tests that used the id as a stand-in for a 200K model now use DEFAULT_LIMITS
or an unlisted id, so each still covers the default-window branch it was
written for.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (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