Repository navigation
fix(llm): prompted JSON for models refusing forced tools, mid-stream quota classification - #391
Merged
Merged
Conversation
…quota classification
filipeforattini
enabled auto-merge (squash)
September 23, 2026 18:07
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.
Plan wave 1, item 3 (
llm-forced-tool-and-quota): A4 + A5.A4:
LLM.generateObjectwithout a forced tool choiceLLM.supportsForcedToolChoice(modelID, declared?)inpackages/llm/src/llm.ts(Claude Opus >= 5.5, Fable, Mythos refuse;declared === falsewins).ProviderTransform.supportsForcedToolChoicein redcode now delegates to it (redcode -> llm dependency direction).ModelCompatibility.forcedToolChoicelets a model or router declare the refusal on an llmModel.generateObjectsends no tools/tool_choice, appends a system instruction with the JSON Schema, decodes the reply (fences stripped) against the same schema, and repairs once (same shape as fix(provider): never force a tool choice on models that refuse one #377 forAgent.generate). A second failure is anInvalidProviderOutputLLMError.A5: mid-stream quota / content-policy classification
streamProviderErrorinpackages/llm/src/provider-error.tsreusesisQuotaFailure/isContentPolicyFailure(the fix(provider): classify gateway quota exhaustion and 402 as non-retryable #378 classifiers). A stream has no status, so throttle shapes (rate_limit_error,rate_limit_exceeded, BedrockthrottlingException) stand in for 429.classification: "quota",retryable: false, message with the sharedQUOTA_HINT; content policy ->classification: "content-policy",retryable: false.ProviderFailureClassificationgainsquotaandcontent-policy.QUOTA_HINTmoved to llm and reused byprovider/error.ts.ResponseStreamError(refusal), whichMessageV2.fromErrorrecords asmetadata.classification, andSessionRetry.retryablenever retries it, whatever the message pattern says. (Before, it becameNamedError.Unknown, and the quota hint's "exhausted" would have read as an overload.) The v2 runner already never retries provider-error events.Tests
packages/llm/test/generate-object.test.ts: capability table, prompted path, one repair, failure after repair, declared refusal.packages/redcode/test/session/retry.test.ts: classified stream refusal is not retried.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.