Skip to content

feat(gateway): carry each model's context size to the harness - #308

Merged
outofcoffee merged 7 commits into
mainfrom
feat/gateway-model-limits
Nov 30, 2026
Merged

outofcoffee merged 7 commits into
mainfrom
feat/gateway-model-limits

Conversation

@outofcoffee

Copy link
Copy Markdown
Collaborator

A harness launched through a fleet gateway now shows the window the engine actually serves — and the output limit derived from it — instead of the harness's schema default.

Summary

  • CDK (control plane): the stats and start Lambdas now carry contextSize in their replies (from the stored deploy config), alongside the runner and served name.
  • Daemon & metrics: the served record records the context size (parsed from CONTEXT at start), so /v1/status and /v1/metrics report it.
  • Cloud node: the status and stats replies map contextSize from the control plane, so a cloud node's facts carry it like a local node's.
  • Gateway: GET /v1/models lists each model with the context size the gateway knows — the running node's report, or the size the config a wakeable stopped node would start with declares — as an extra field clients ignore.
  • Harness apply: DiscoveredModels is now typed ({ID, ContextSize}); a discovered model the gateway reports a size for is written with limit: {context, output} — the context as reported, the output derived the same way a Spinloop applies it (a quarter of the context, minimum 1) — and one with no reported size is listed unlimited.

Implementation details

  • The context size travels as a fact in replies, never re-derived per request: the gateway carries it on each models list item, and the launch reads it from that list.
  • A running node's size comes from its own report (never its source's model or size); a stopped wakeable node's comes from the config it would start with.
  • The output limit is derived, never stored: contextsize.DefaultOutput(context) — the same derivation the Spinloop apply uses — so the harness shows a window and a matching output limit rather than the harness's own default (opencode's 200000/32000).
  • No gateway stack change: only the two control-plane Lambdas changed, deployed to the account (cloud-vm-llm StatsFn and StartFn updated). The gateway stack was redeployed with the new binary; the deployed gateway reports qwen3.8-27b with contextSize: 196608, and a launch through it writes limit: {context: 196608, output: 49152} into the harness config.

@outofcoffee
outofcoffee marked this pull request as ready for review November 30, 2026 10:31
@outofcoffee
outofcoffee merged commit 52acbe9 into main Nov 30, 2026
6 checks passed
@outofcoffee
outofcoffee deleted the feat/gateway-model-limits branch November 30, 2026 10:31
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