Repository navigation
fix(agent-runtime): read Perplexity and MiniMax max_tokens ceilings - #2363
Merged
Merged
Conversation
Perplexity's "max_tokens must be at most N" and MiniMax's "does not support max tokens > N" are output ceilings, but the parser did not recognize them. The 400 stayed a terminal provider error, so the turn never clamped max_tokens and retried. A context sum worded "plus max_tokens must be at most N" stays unrecognized, and MiniMax's trailing business code is not the ceiling.
vastsa
approved these changes
Nov 15, 2026
vastsa
left a comment
Owner
There was a problem hiding this comment.
Independently reproduced the missing ceiling parsing and repair: candidate tests on baseline production module yield 5 failures; candidate and integration pass 187/187 agent-errors/provider-retry tests. Built the production sidecar and ran e2e-provider-retry-idle: abort-backoff, retry-after and stalled-request all passed with expected request counts. Reviewed context-sum negative cases and bounded repair behavior. Refreshed integration after #2359 (SQLite-only): targeted tests pass again; runtime executable inputs unchanged. All six Actions green; no live provider requests.
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.
Fixes #2362
Summary
outputTokenCeilingnow reads Perplexity'smax_tokens must be at most Nwording (backticks optional; alsomax_completion_tokens/max_output_tokens) and MiniMax'sdoes not support max tokens > N. A 400 of either shape takes the existing one-shot clamp repair instead of ending the turn.Root cause
The ceiling parser already covered OpenAI, Anthropic, proxy
<=, DeepSeek / DashScope ranges, and Groqmust be less than or equal to, but not these two sentences.isOutputLimitRejectiontherefore stayed false and the retry factory never clamped the derived output limit.Fix
max_tokens must be at most N, with a lookbehind soPrompt tokens plus max_tokens must be at most N(a context sum) is not treated as an output ceiling.does not support max tokens > N. The parenthesized MiniMax business code is not captured.Tests
provider-retry.test.ts: Perplexity with and without backticks,max_completion_tokens/max_output_tokens, the official JSON 400,InvalidRequestError: max_tokens must be at most 4096; MiniMax including(2013);isOutputLimitRejectionon both 400s and the "plus max_tokens" negative; clamp-and-retry for both payloads (attempts === 2,max_tokensset to 128000 / 196608). Negatives forPrompt tokens plus max_tokens must be at most 131,072with and without backticks.main@525ec4986):provider-retry5 failed / 60 passed (65). After: 65/65.tsc -p packages/agent-runtime/tsconfig.json --noEmit: exit 0.Scope
provider-retry.tsand its tests.