Skip to content

Never send an output cap of 0 for a model with an unknown limit - #467

Merged
ilovepixelart merged 1 commit into
mainfrom
fix-unknown-output-limit
Nov 16, 2026
Merged

ilovepixelart merged 1 commit into
mainfrom
fix-unknown-output-limit

Conversation

@ilovepixelart

Copy link
Copy Markdown
Owner

The `/goal` evaluator (`extensions/goal.ts`) and `type: prompt` hooks (`extensions/hooks/runners.ts`) pass the model's output limit as their cap. pi registers a model without a declared limit, such as a virtual model from `registerVirtualModel`, with `maxTokens: 0`, meaning unknown.

  • Evaluations and prompt hooks on such a model no longer fail. The 0 went out as the cap: `ModelRuntime` clamps a routed request only when `maxTokens` is truthy, so the routed Anthropic request carried `max_tokens: 0`. Every `/goal` evaluation errored and left a met goal active, and every prompt hook exited 1, which lets a PreToolUse prompt gate's tool run. `modelOutputLimit` (`extensions/internal/model-complete.ts`) now passes a positive limit as is and leaves an unknown one unset, so the completion default (1024) applies.

  • `npm run check` passes (Biome, strict tsc, Vitest)

  • Tests cover the change

pi gives a model without a declared output limit, such as a virtual
model, maxTokens 0, meaning unknown. The goal evaluator and prompt
hooks passed it as their cap, so a routed Anthropic request carried
max_tokens: 0 and every evaluation and prompt hook failed; a failing
PreToolUse prompt gate lets the tool run. An unknown limit now falls
back to the completion default.
@sonarqubecloud

Copy link
Copy Markdown

@ilovepixelart
ilovepixelart merged commit 855171f into main Nov 16, 2026
13 checks passed
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