Repository navigation
Never send an output cap of 0 for a model with an unknown limit - #467
Merged
Merged
Conversation
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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