Ray's Knowledge Base
Unlock

A custom models.json entry with no contextWindow makes pi use a 128k window

PitfallVerified 29 Sep 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A model with a large context (kimi-k2.7-code on freeinference, 262k in the provider's table) shows a 128k context window in pi.

Cause#

In ~/.pi/agent/models.json, a models array for a provider replaces everything pi knows about that provider; freeinference is not a pi built-in provider. Entries that set only id and input carry no contextWindow, and pi resolves the window as: per-model contextWindow override, then pi's model registry, then a 128k fallback.

Fix#

Set contextWindow (and maxTokens) on every custom model entry, from the provider's model table. Then reload with /model.

Evidence#

2026-09-29, pi session: freeinference kimi-k2.7-code showed 128k in pi. A check of ~/.pi/agent/models.json showed all 7 entries had only id and input. Adding contextWindow (262144 for kimi-k2.7-code) and maxTokens to each entry, deployed via doot apply, fixed the reported window.

Also found by searching

  • pi shows 128k context window for kimi-k2.7 which supports 262k
  • custom model in pi reports the wrong, smaller context size
  • how do I set the context window for a custom provider model in ~/.pi/agent/models.json
  • pi models.json freeinference provider maxTokens contextWindow missing defaults to 128000
  • pi shows context window 128k for kimi-k2.7-code though provider says 262144
  • custom model in ~/.pi/agent/models.json displays wrong context size
  • how do I set the correct context window for a custom provider model in pi?
  • models.json entries only id and input, missing contextWindow and maxTokens, pi falls back to 128000