Command Code reads a model's context window and output limit from
providers.json alone: its parseModel2 takes raw.contextWindow (or
limit.context) and raw.maxOutput (or limit.output), its getContextLimit
falls through to its own 200K default when both miss, and its catalog
lookup keys on the bare vendor id, so "magpie/deepseek-v4.1-flash"
never matches the embedded "deepseek/deepseek-v4.1-flash" — and it
never interrogates the gateway's /v1/models. magpie's entry carried
only name, reasoning and reasoningEfforts, so a 1M-window model was
served to Command Code as a 200K one and compacted long before it had
to; the same model's dsh entry carried both numbers, per model.
ccProviderJSONAt now writes the pair the way piModelJSON does: the
window as m.Context when it is known, the reply limit as maxTokens(m)
when the model declares an output, under Command Code's own names,
contextWindow and maxOutput. A model with no output declared carries
no maxOutput.
Checked against Command Code's own bundle (command-code 1.74.1,
dist/cli.mjs): it reads contextWindow ?? limit.context and
maxOutput ?? limit.output for a providers.json model.
Run on mote at this tree: go test -tags nogui -run TestCommandCode
./internal/agent ok. TestCommandCodeModelLimits is red with main's
commandcode.go put back ("pro contextWindow <nil>, want 1048576"), and
red with the Output > 0 guard dropped ("flash carries maxOutput 0 with
no output declared"); green restored. gofmt -l clean.
Not tried: a real Command Code session against the gateway.
Reported-by: becausemadoka
Co-authored-by: ggbdpq <ggbdpq@gmail.com>