Skip to content

Overloads mid-reply hold the provider's pool, an empty reply after a tool call ends the turn, keep the answer a steer came after - #233

Merged
lydakis merged 3 commits into
mainfrom
claude/project-thread-51pp6w
Oct 28, 2026
Merged

lydakis merged 3 commits into
mainfrom
claude/project-thread-51pp6w

Conversation

@lydakis

@lydakis lydakis commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Fixes for turns that failed, or lost their answer, in a day of heavy use.

Changes

  • An overload mid-stream holds the pool and is retried. Once a stream has begun, Anthropic reports overloaded_error and rate_limit_error as an SSE error event. Both mapped to provider_error, which is final, so a busy provider failed the turn with no retry. They now map to provider_http_529 and provider_rate_limited, the codes the same refusal gets before the stream begins. Like those, they close the model's pool for every bot through the pacer: 1 s, doubling up to 32 s while refusals go on. A 529's retry now waits on the pool the way a rate limit's does. A turn that would wait 250 ms or more parks without its slot and resumes when the pool reopens.
  • A stalled stream waits seconds before its retry. Its backoff starts at 2 s (2, 4, 8, 16, 30 s) instead of 250 ms. A stall resent 250 ms later with the same large context stalled again.
  • An empty reply after a tool call ends the turn. A model that reacts (a declared tool) and then has nothing to add returns an empty message. That failed the turn as empty_completion and showed it as failed.
    • Once the model has replied in the turn, an empty reply now ends it as completed, with no item stored (Messages refuses an empty assistant turn).
    • This also holds after the turn parked on a wait, a verdict or its pool, and resumed.
    • An empty reply to a prompt, and an empty summary, still fail.
  • A turn handle keeps the answer a steer came after. wait returned only a turn's final text. When a reviewer was steered after writing its review, its final text was its reply to the steer ("already reported in my last reply"), and the review was lost. A turn's result now carries before_steer: the last text it wrote before its last steer, when that differs from the final text.
  • read refuses binary files. Reading a PNG put its bytes into context. read now fails with file_not_text and a detail naming the kind: PNG, JPEG, GIF, WebP, PDF, zip, executable, or binary file. The last is any file with a NUL byte in its first 8 KiB, which is git's rule.
  • agent ls | head no longer panics. CLI output that hits a closed pipe exits quietly with status 0 instead of panicking with status 101.

Testing

  • cargo test --workspace: all pass, except the two sandfs task tests, which fail the same way on main in a container without FUSE.
  • cargo clippy --workspace --all-targets and cargo fmt --check are clean.
  • New tests:
    • Unit tests:
      • mid-stream overload and rate-limit mapping
      • which refusals hold the pool
      • stall backoff
      • binary detection, and read on an image
    • Runtime tests:
      • An empty reply after a tool call completes the turn, and the next prompt works. An empty reply to a prompt fails.
      • The same holds after an approval-gated call parks the turn and it resumes. This test fails without the fix.
      • A mid-stream overload parks the turn on its closed pool and is retried once.
      • A steered turn's handle carries before_steer.
  • Every Python suite except the soak, bench and eval ones, run with AGENT_TEST_RUNTIME=1 against a release build: 396 tests, OK (6 skipped).
  • Broken pipe, checked by hand against a daemon with 300 bots: agent ls --pretty | head -1 exits 101 with a panic on main and 0 with this change.

No visible UI change, so no screenshots.

🤖 Generated with Claude Code

…y after a tool call, keep the answer a steer came after

- An overload or rate limit that Anthropic sends after the stream began is
  the 529 or 429 it would have been before it, and is retried as one; it
  failed the turn with provider_error and no retry.
- Retries after an overload or a stall start at 2 s instead of 250 ms: a
  stall resent at once with the same context stalls again.
- An empty reply once the model has replied in the turn, as after a
  reaction with nothing to add, ends the turn; an empty reply to a prompt
  or an empty summary still fails as empty_completion.
- A turn handle's result carries before_steer, the last text the turn
  wrote before its last steer, when it then ended on a reply to the steer.
- read refuses an image or other binary file with file_not_text, naming
  its kind, instead of putting its bytes in context.
- A command whose output reader stops reading (| head) exits quietly
  instead of panicking.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHW3CCrgg5qbk2KQVA
@lydakis lydakis self-assigned this Oct 27, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-28T00:03:34.384156Z 80c8dce Manual request
🔒 Security Review ✅ Completed 2026-10-28T00:04:40.692364Z 80c8dce Manual request
ℹ️ About Codex in GitHub

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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e8dfe5554

ℹ️ About Codex in GitHub

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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/turn.rs Resolved
…s reply on resume

An overloaded_error inside the stream now closes the model's pool as an
HTTP 529 does, and its retry waits on the pool like a rate limit; only a
stalled stream keeps its own seconds-long backoff. A turn that parked on a
call the model made, or on its pool after one, still counts as having
replied when it resumes, so an empty reply then ends it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHW3CCrgg5qbk2KQVA
@lydakis lydakis changed the title Retry overloads after a pause, end a turn on an empty reply after a tool call, keep the answer a steer came after Overloads mid-reply hold the provider's pool, an empty reply after a tool call ends the turn, keep the answer a steer came after Oct 28, 2026

lydakis commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 80c8dce8ce

ℹ️ About Codex in GitHub

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

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 80c8dce8ce

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

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.

2 participants