Skip to content

Stop Claude Code from retrying the mock's deliberate 400 - #201

Merged
Abhijeet Prasad (AbhiPrasad) merged 3 commits into
mainfrom
fix/claude-max-retries
Oct 19, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 3 commits into
mainfrom
fix/claude-max-retries

Conversation

@AbhiPrasad

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Summary

claude_session_emits_traces started failing in the Daemon job on all platforms ("Test coding-agent integrations with deterministic inference", e.g. run 39333251206) once CI picked up Claude Code 2.1.304. The last green main run (39312258447) used 2.1.303.

The mock answers request 2 with a deliberate HTTP 400 invalid_request_error. Claude Code 2.1.304 now sends another request after that 400, which lands in the mock's panic! arm. Two separate mechanisms cause it:

  1. Retries. 2.1.304 started retrying 400s. The harness was meant to disable retries, but it set ANTHROPIC_MAX_RETRIES=0, and Claude Code never reads that variable. Claude Code's own limit is CLAUDE_CODE_MAX_RETRIES.
  2. ToolSearch fallback. With retries off, 2.1.304 still reissues the request after the 400. The new request has ToolSearch removed and adds the note "ToolSearch is no longer available. Tools listed earlier as deferred that are still available are declared in full." CLAUDE_CODE_MAX_RETRIES doesn't govern this fallback. In 2.1.301, ToolSearch is off by default when ANTHROPIC_BASE_URL isn't a first-party host, so this path never ran there.

Changes

  • tests/support/agents/claude.rs: set CLAUDE_CODE_MAX_RETRIES=0 (instead of ANTHROPIC_MAX_RETRIES=0) and ENABLE_TOOL_SEARCH=false. A falsy value selects Claude Code's standard tool mode, so the run never starts with ToolSearch and there's nothing to fall back from.
  • tests/support/inference/mod.rs: add an error_response helper that sends x-should-retry: false. Claude Code's HTTP retry check honors this header before it looks at the status code.
  • tests/support/inference/anthropic.rs: use error_response for the decode-error reply and for MockReply::HttpError.

The OpenAI mock is unchanged. The panic arm and the == 3 request-count assertion are also unchanged.

Testing

  • claude_session_emits_traces passes locally on Claude Code 2.1.301 (exactly 3 requests).
  • My npm's minimum-release-age policy blocks 2.1.303 and 2.1.304, so this PR's CI run is the check on 2.1.304.
  • cargo fmt --check and cargo clippy --all-features --all-targets -- -D warnings are clean.

🤖 Generated with Claude Code

Claude Code 2.1.304 retries the deterministic 400 returned by the
Anthropic mock, so claude_session_emits_traces hits the mock's panic arm
and times out. The harness set ANTHROPIC_MAX_RETRIES, which Claude Code
never reads; it honors CLAUDE_CODE_MAX_RETRIES. The Anthropic mock now
also sends x-should-retry: false on error replies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T22:48:15.748020Z 35c997b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…request

After the deterministic 400, Claude Code 2.1.304 reissues the request
with ToolSearch disabled. That fallback ignores CLAUDE_CODE_MAX_RETRIES.
Start with ToolSearch off so the fallback never applies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit 599b20c into main Oct 19, 2026
22 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the fix/claude-max-retries branch October 19, 2026 23:29
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