Skip to content

fix(plugin): seed the catalog context window instead of the 128k fallback - #8

Merged
JeffreyJYZ merged 4 commits into
mainfrom
fix/seed-model-context
Nov 8, 2026
Merged

JeffreyJYZ merged 4 commits into
mainfrom
fix/seed-model-context

Conversation

@jyzbot

@jyzbot jyzbot commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Problem

A 1M-context model reported a 128k window, so the host compacted at roughly 81k. Measured on command-code-openai/deepseek/deepseek-v4.1-flash:

  • live listing API: {"id":"deepseek/deepseek-v4.1-flash","contextLength":1000000}
  • src/catalog.ts: context: 1000000
  • context_breakdown: limit.context = 128000

Cause

staticSeedModels() seeded every model with contextLength: 0, and toV2Model turns 0 into DEFAULT_CONTEXT_LENGTH (128_000). The seed is what the host registers before the live list merges, so the fallback won whenever the session bound to a seeded entry. The catalog already held the real figure but exposed no accessor for it.

Fix

  • catalog.ts: new modelContext(id) accessor, matching the existing modelCost / minPlan shape.
  • v2.ts: the seed passes modelContext(id) ?? 0 into toV2Model.
  • 0 keeps meaning "unknown": a catalogued 0 or an unlisted id still falls back to DEFAULT_CONTEXT_LENGTH.
  • Tests: the seed test now asserts each model's window equals the catalog value (and pins DeepSeek V4.1 Flash at 1_000_000); the catalog test covers modelContext for a known and an unknown id.
  • Version 0.5.24.

The v1 half is untouched — it awaits the live list and never seeds.

Verification

bun test        246 pass, 0 fail
bun check       No type errors in 57 files
bun fmt --check All 64 files are formatted
bunx biome lint src test   Found 2 warnings (pre-existing)
bun run build   bundled, stripped

bun build writes `// <module path>` above every inlined module, and the
path depends on the install: a bun workspace shows
`node_modules/zod/...` while CI shows
`../node_modules/.bun/zod@4.1.8/node_modules/zod/...`. The code is
byte-identical, but verify-release.ts hashes the tarball, so a healthy
publish read as "served bytes do not match the local pack — do not
install".

The build now drops those comments, which also stops the bundle leaking
an install path.
…back

staticSeedModels passed contextLength 0 for every model, so toV2Model fell
back to DEFAULT_CONTEXT_LENGTH (128k) and a 1M-context model compacted at a
fifth of its real window until the live list arrived. Seed from the catalog
through a new modelContext accessor; an unknown or 0 context keeps the
fallback. Bumps to 0.5.24.
@vercel

vercel Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cmdcode-tools-site Ready Ready Preview Nov 6, 2026 12:10pm UTC

@JeffreyJYZ
JeffreyJYZ merged commit 0b82e5c into main Nov 8, 2026
10 checks passed
@JeffreyJYZ
JeffreyJYZ deleted the fix/seed-model-context branch November 8, 2026 05:25

This branch was successfully deployed

1 active deployment
Preview — d59f9565 Deployed Nov 6, 2026 by vercel[bot]
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.

2 participants