Registry Mirror
Skip to content

Conversation

@immakermatty

@immakermatty immakermatty commented Oct 15, 2026 •

Copy link
Copy Markdown

Claude Code Agent SDK threads repeatedly fail with HTTP 400 because CLIProxyAPI derives a new Anthropic-Beta header from a delta request that omits the tools used to derive the creation header. The client then replays the entire conversation, increasing failure counts and latency.

This change retains the exact upstream beta header with the existing bounded per-message tool-alias state, shared by scoped executor copies. Continuations reuse that header when the SDK omits optional betas or explicitly names an already emitted beta. Missing state, a changed account/upstream, a genuinely new caller beta, or changed operator beta overrides returns the existing request-scoped 404 replay signal. An incomplete delta is never sent to a different account. OAuth token changes under the same auth record remain compatible with the cached state. Business payloads remain unchanged after operator payload rules.

The fork's main and dev branches were synchronized by fast-forward to upstream 5be2cda before this fix. This PR changes only four Claude executor/test files. The existing routing, quota cooldowns and account priorities are preserved. Runtime rollout is limited to the operator's local macOS installation; organization fleets are outside this change.

Validation:

  • Red/green regressions reproduce the upstream beta mismatch in both JSON and SSE paths and the unnecessary replay caused by optional caller beta changes.
  • Four-account integration exercises the real manager and sticky selector: a simulated 5h rejection, a request-scoped replay on failover, and successful continuation on the replacement account.
  • Regressions cover scoped executor copies, token changes, missing state, changed upstream, added/removed/restored caller betas and operator overrides.
  • Full GOMAXPROCS=4 go test -p 4 ./... passes on b1735ad. An earlier unrelated WebRTC test timed out during initial compilation; isolated rerun and both subsequent full suites pass.
  • GOMAXPROCS=4 go test -p 2 -race ./internal/runtime/executor ./sdk/cliproxy/auth passes on b1735ad.
  • ARM64 server build passes on b1735ad.
  • Live isolated canary of the first patch: real Claude thread creation plus three delta turns all return HTTP 200 and retain a synthetic remembered word.
  • Real Claude CLI: three consecutive streamed turns complete and retain the synthetic word.
  • Initial local deployment eliminated the original upstream beta mismatch while real T3 tasks continued completing. Live observation exposed the optional-header replay case covered by the final regression above.
  • Final b1735ad local rollout: three real HTTP 200 turns retain the synthetic word while optional caller betas are removed and restored; no retries are needed. Actual T3 requests continue succeeding after the expected restart/replay window.
  • GitHub has no required checks; the available Macroscope check was skipped. Go validation was run locally, not inferred from CI.

Thread state remains bounded and in memory. Restarts, executor replacement and eviction can require the client's full replay; actual provider quotas and outages remain possible. Historical failure counters are not evidence of new failures. No credential material, user prompts, or account identities are included.

@immakermatty
immakermatty marked this pull request as ready for review October 15, 2026 22:25
@immakermatty
immakermatty changed the base branch from dev to main October 15, 2026 22:26
@immakermatty
immakermatty merged commit 0e599a5 into main Oct 15, 2026
1 check passed
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