Skip to content

Per-model context-window defaults for chat agents (stop the silent 4096 fallback) - #247

Merged
TheGreatAxios merged 4 commits into
cl-6204-inference-adapterfrom
cl-context-window-default
Aug 21, 2026
Merged

TheGreatAxios merged 4 commits into
cl-6204-inference-adapterfrom
cl-context-window-default

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

Summary

  • Chat agents served through Ollama's openai-compatible endpoint silently ran at @intx/inference's built-in options.maxTokens ?? 4096 fallback, and at whatever small num_ctx Ollama itself defaults to, whenever nothing set a per-model ceiling -- the model catalog seeded no context/token data at all.
  • @corbits/ollama-adapter (this branch's base, CL-6204: Ollama adapter overrides via the inference adapter manifest #236) built the mechanism to override num_ctx/max output tokens/reasoning effort per model, but nothing populated it with real values.
  • Adds quirksForDeployment (packages/inference-catalog/src/ollama-context-defaults.ts), resolved the same way capabilitiesForDeployment resolves capabilities: gpt-oss:20b and llama3.1:8b get their real 128K native context window, Qwen3's 27B/30B-class models get their real, smaller 32K native ceiling (not an over-requested num_ctx that risks allocation failure or heavy swap on the inference host). A model outside the table gets no override, and a caller-supplied override always wins.
  • Wires it into seedCatalog (packages/hub-client/src/seed.ts) right alongside capabilitiesForDeployment, so a seeded Ollama offering's quirks column actually carries it -- @intx/hub-api already persists quirks on model_offering and the platform's own InferenceSource resolution already spreads a non-null quirks column into the request-build path, so this is the one place workbench needed to close the gap. Scoped to the ollama provider only; every other provider is untouched.

Verification

Confirmed the value actually reaches the built request body, not just the resolved config: a test builds a real request through createOllamaAdapter with the resolved quirks and asserts body.options.num_ctx and body.max_tokens -- proving gpt-oss:20b carries 131072/32768 (not 4096) and qwen3.8:27b carries its own smaller 32768 ceiling.

Test plan

  • bun test in packages/inference-catalog (75 tests, incl. new ollama-context-defaults.test.ts)
  • bun test in packages/hub-client (159 tests, incl. new seeding-wiring case in seed.test.ts)
  • tsc --noEmit in both packages
  • prettier --write on every changed file

Chat agents served through the Ollama openai-compatible adapter silently
fall back to @intx/inference's built-in 4096-token default (and Ollama's
own small built-in context window) whenever nothing sets a per-model
ceiling. These tests pin the fix: a curated model's quirks resolve its
real advertised context window, a smaller-ceiling model gets its own
limit rather than the larger model's, a caller override wins, and an
unlisted model gets no guessed override at all -- verified against the
adapter's actual built request body, not just the resolved config.
@corbits/ollama-adapter's OllamaAdapterConfig mechanism (numCtx,
maxOutputTokens, reasoningEffort) had no real data behind it, so every
Ollama-served chat agent still ran at the built-in 4096-token default.
quirksForDeployment resolves each curated model's advertised native
context window at offering-creation time, the same way
capabilitiesForDeployment resolves capabilities -- gpt-oss:20b and
llama3.1:8b get their real 128K ceiling, Qwen3's 27B/30B-class models get
their smaller 32K native ceiling rather than an over-requested num_ctx
that risks allocation failure or heavy swap on the inference host. A
model outside this table gets no override, and a caller-supplied override
always wins.
seedCatalog computed capabilities for a new offering but never its
quirks, so nothing ever reached the model_offering row an Ollama chat
agent actually launches against. This test seeds Ollama's curated
catalog and asserts each offering's POST body carries the per-model
quirks quirksForDeployment resolves -- gpt-oss:20b's real 128K ceiling,
Qwen3's smaller real ceiling -- rather than an empty quirks column.
ensureCatalogOffering now threads a quirks value through to the offering
POST body -- @intx/hub-api already persists it on model_offering.quirks,
and the platform's own InferenceSource resolution already spreads a
non-null quirks column into the request-build path, so this is the one
place workbench needed to populate it. seedCatalog computes it with
quirksForDeployment right alongside capabilitiesForDeployment, scoped to
the ollama provider only; every other provider's offerings are
unaffected, and a model with no vetted default still gets none.
@TheGreatAxios
TheGreatAxios merged commit 42edc80 into cl-6204-inference-adapter Aug 21, 2026
2 checks passed
@TheGreatAxios
TheGreatAxios deleted the cl-context-window-default branch August 25, 2026 15:29
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