Repository navigation
feat(aikit): retry non-strict when Claude's strict-tool limits are exceeded - #127
Merged
Merged
Conversation
…ceeded Claude rejects the whole request when strict tools exceed 20 tools or 16 optional/union-typed parameters. On that 400, retry once with `prefer` tools sent non-strict; `require` tools stay strict. The retry is recorded as a `strictToolsFallback` diagnostic on the assistant message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Claude rejects the whole request when strict tools exceed 20 tools, or 16 optional/union-typed parameters across all strict tools. Previously strict fallback was per schema only, so our
preferbuilt-in tools plus one more strict tool could push every Claude request into a 400.invalid_request_errorwith Claude's limit message), the stream retries once withprefertools sent non-strict;requiretools stay strict. Only requests on Anthropic's message format, refused before anything streamed, with at least oneprefertool sent strict, are retried.llm/failure.ts;resolveStrictParameters/convertToolstake apreferNonStrictflag.AssistantMessagegains optionaldiagnostics; the retry records{ type: "strictToolsFallback", details: { reason: "strictToolLimits" } }with Claude's message.Tests
packages/aikit/test/e2e/strict.limit.e2e.test.ts: tool-count (22 strict) and union-count (17 optional params) cases, recorded (fake server replaying Claude's real 400s) and live against claude-sonnet-4-6. Both write__artifacts__/strict-tool-limit.jsonwith each attempt's per-tool strict flags.vp checkandvp run typecheckpass.🤖 Generated with Claude Code