Repository navigation
feat(model-server): opt-in HTTP 529 retry for thinking-only /v1/messages turns - #4027
Open
linj-glitch wants to merge 7 commits into
Open
linj-glitch wants to merge 7 commits into
linj-glitch wants to merge 7 commits into
Conversation
linj-glitch
marked this pull request as draft
October 5, 2026 06:11
linj-glitch
force-pushed
the
linj/anthropic-thinking-only-retry
branch
2 times, most recently
from
October 8, 2026 00:20
d083ece to
997792a
Compare
linj-glitch
marked this pull request as ready for review
October 13, 2026 23:27
…ges turns A reasoning model sometimes ends a generation inside an unclosed <think>: the reasoning parser yields reasoning but no content and no tool call, and /v1/messages returns a message whose only block is "thinking" with stop_reason end_turn. Claude Code then appends "[Your previous response had no visible output. Please continue and produce a user-visible response.]" and re-sends the history with the earlier thinking stripped. For RL this is doubly bad: the trajectory gets a synthetic user turn, and the re-rendered history no longer extends the prompt of the previous call, so token-capture lineage breaks. In one Claude Code RL run about 30% of rollouts hit this by step 48. With anthropic_thinking_only_max_retries=N the server answers such a turn with HTTP 529 overloaded_error (x-should-retry: true, retry-after: 1). The Anthropic SDK retries 529, so the client re-issues the unchanged request. After N retries for the same request body (digest-keyed, bounded, per-process tally) the thinking-only message is served as before, so a model that keeps doing this still terminates. The sampled generation is finalized before the 529 so external token staging does not leave an uncommitted call behind. Default 0 keeps today's behavior. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Lin Jia <[email protected]>
Signed-off-by: Lin Jia <[email protected]>
linj-glitch
force-pushed
the
linj/anthropic-thinking-only-retry
branch
from
October 19, 2026 04:37
3593ca9 to
c9d977f
Compare
Collaborator
Author
|
/ok to test c9d977f |
Contributor
This was referenced Oct 22, 2026
Signed-off-by: Lin Jia <[email protected]>
Collaborator
Author
|
/ok to test 25d670f |
Signed-off-by: Lin Jia <[email protected]>
Collaborator
Author
|
/ok to test bb8120b |
Signed-off-by: Lin Jia <[email protected]>
Collaborator
Author
|
/ok to test b9f7705 |
Signed-off-by: Lin Jia <[email protected]>
Collaborator
Author
|
/ok to test 2f40670 |
Signed-off-by: Lin Jia <[email protected]>
Collaborator
Author
|
/ok to test 565a1b8 |
This branch was previously deployed
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.
Add the default-off
anthropic_thinking_only_max_retriesoption to the shared/v1/messagesadapter: a completedend_turnwith no visible text or tool call returns HTTP 529 withx-should-retry: true, so an Anthropic SDK can retry the unchanged request; truncations and other terminal outcomes return normally.Retry budgets are private to each model instance and keyed by rollout ID plus request-body digest, require the stable
/ng-rollout/<rollout-id>/v1/messagespath, expire after one idle hour, and cap at 4096 active identities without evicting existing budgets; unprefixed requests fall through normally, visible or other terminal responses and exhausted-budget fallbacks clear the allowance, and sampled generations are finalized before 529 so capture calls are committed.Retries are per process and resample failed-visible-output turns at the cost of extra model calls, so benchmark configurations must record the option and the client's retry allowance must cover the server limit; clients that do not retry 529 receive the error, and default zero retains existing behavior.
Validated head
565a1b8149a765db85add07edf9ce6d4ba2def98additively merges mainf70bf75c3c3eef60484044fc0cd992ff97f12029: the import conflict resolution retains this PR'sOrderedDictretry budget and main'sAwaitablestreaming support from #5155. Independent review confirms the existing retry helpers, main's keepalive streaming, and capture behavior are preserved. Python 3.13 source-bound Anthropic, model, streaming, checkpoint-model, and token-capture tests pass 998 cases;pre-commit run --all-files, final diff/body guardwords, andgit diff --checkpass.Earlier independent-rollout and visible-reset regressions failed on the prior implementation and pass with the fix, while the Anthropic SDK 0.109.2 loopback smoke used deterministic thinking-only then visible responses and confirmed identical-request retries, two model calls, visible output, and cleared accounting for JSON and SSE; that smoke and the original motivating Claude Code run were not rerun for this main integration, and no fresh real-model or benchmark-quality result is claimed.
This focused PR defines the opt-in retry contract without a separate issue, includes documentation and DCO sign-off, and was developed with AI assistance; current-head required CI and normal repository approval gates still apply.