Skip to content

feat(aikit): retry non-strict when Claude's strict-tool limits are exceeded - #127

Merged
sanchitrk merged 1 commit into
canaryfrom
claude/cod-200-strict-limit-218541
Nov 1, 2026
Merged

sanchitrk merged 1 commit into
canaryfrom
claude/cod-200-strict-limit-218541

Conversation

@sanchitrk

Copy link
Copy Markdown
Contributor

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 prefer built-in tools plus one more strict tool could push every Claude request into a 400.

  • On that 400 (invalid_request_error with Claude's limit message), the stream retries once with prefer tools sent non-strict; require tools stay strict. Only requests on Anthropic's message format, refused before anything streamed, with at least one prefer tool sent strict, are retried.
  • The matcher lives in llm/failure.ts; resolveStrictParameters / convertTools take a preferNonStrict flag.
  • AssistantMessage gains optional diagnostics; 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.json with each attempt's per-tool strict flags. vp check and vp run typecheck pass.

🤖 Generated with Claude Code

…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>
@sanchitrk
sanchitrk merged commit 133d652 into canary Nov 1, 2026
2 checks passed
@sanchitrk
sanchitrk deleted the claude/cod-200-strict-limit-218541 branch November 1, 2026 13:17
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