Skip to content

Ask Anthropic for each model's full output limit and give busy callers exact flags - #15

Merged
lydakis merged 4 commits into
mainfrom
claude/project-thread-4opvst
Sep 25, 2026
Merged

lydakis merged 4 commits into
mainfrom
claude/project-thread-4opvst

Conversation

@claude

@claude claude Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Before: every Anthropic call capped max_tokens at 32,768. A Sonnet 5 benchmark task hit that cap mid-answer and failed with provider_incomplete "max_tokens". A bot that tried to talk to a busy bot got a prose hint ("retry with delivery steer…") that it ignored.

After: each Anthropic call asks for the model's full output limit. That is 128,000 for Claude 4.6 and later, 64,000 for Haiku 4.5, Sonnet 4.5, Opus 4.5, Sonnet 4 and Sonnet 3.7, 32,000 for Opus 4 and 4.1, and 8,192 or 4,096 for the Claude 3.5 and 3 models. The bot_busy detail now gives flags to copy: --delivery steer --turn N, --delivery queue, and fork --source NAME --bot NEW. When no turn is running, it offers only queue and fork.

Performance cost

  • Anthropic counts only generated tokens against output rate limits (rate limits, read 2026-09-25), so a higher cap costs nothing until it is used.
  • The pacer still reserves 512 output tokens per call, so admission is unchanged.
  • The per-response byte bound (MAX_OUTPUT) goes from 512 KiB to 768 KiB. This fits a full 128,000-token answer and stays under the 1 MiB event cap, so every stored item stays readable. Nothing is preallocated: live memory grows only for turns that actually produce output that large.
  • The compaction reserve now scales with the model's limit, still capped at a quarter of the context. At the default 8 MiB context it does not move the compaction trigger.
  • The per-request lookup is a dozen prefix compares.

How

  • anthropic_max_tokens(model) is a prefix table in src/provider.rs, in the same style as legacy_thinking. The Bedrock branch can wrap it with its claude_model() id normalization.
  • output_byte_estimate now takes the model.
  • Legacy thinking budgets are clamped to max_tokens - 1024.
  • The busy detail is built in src/store/db.rs.
  • The 4.6+ and Haiku 4.5 limits come from the models overview (read 2026-09-25). The older values are Anthropic's earlier published figures and were not re-read; docs/RUST_PROTOTYPE.md says so.

Checks

  • cargo fmt --check and cargo clippy --all-targets are clean.
  • cargo test --all-targets: all pass.
  • AGENT_TEST_RUNTIME=1 python3 -m unittest discover -s tests: 252 tests OK, 18 skipped.

🤖 Generated with Claude Code

…s exact flags

A fixed 32,768 max_tokens cut off a Sonnet 5 benchmark answer. Each call now
sets max_tokens to the model's documented limit (128,000 for Claude 4.6 and
later, down to 4,096 for Claude 3 models), legacy thinking budgets stay below
it, and the response byte bound rises to 768 KiB so a full answer fits under
the event cap. Anthropic counts only generated tokens against output rate
limits, so the higher cap costs nothing until used.

The bot_busy detail now names copyable flags: --delivery steer --turn N,
--delivery queue, and fork --source NAME --bot NEW.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013RhkQCvP5uTYjUeMBnFzDp

@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: 9e79cad199

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/provider.rs Resolved
Decoded text can grow up to sixfold as JSON, so a delta of quotes or control
characters under the raw bound could still exceed the 1 MiB event cap. Text
and thinking deltas now count their JSON-encoded length in both parsers.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013RhkQCvP5uTYjUeMBnFzDp
@claude

claude Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

@codex review


Generated by Claude Code

@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: 5fafccbe15

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/provider.rs Resolved
@claude

claude Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

@codex review


Generated by Claude Code

@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: 01fd9d3971

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/store/db.rs Resolved
Fork without a checkpoint is refused during a running turn, so the hint now
names the head the turn started from, and offers no fork on a first turn.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013RhkQCvP5uTYjUeMBnFzDp
@claude

claude Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

@codex review


Generated by Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 286a7775bf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@lydakis
lydakis merged commit f94ac98 into main Sep 25, 2026
1 check passed
@lydakis
lydakis deleted the claude/project-thread-4opvst branch September 25, 2026 02:40
claude Bot pushed a commit that referenced this pull request Sep 25, 2026
PR #15 asks each Claude model for its full output limit. The lookup now
reads the Claude model inside a Bedrock id, so anthropic.claude-haiku-4-5
gets 64,000 rather than the 128,000 default, and --max-output-tokens still
overrides it. BEDROCK.md notes that runtime deducts input plus max_tokens
from quota when a call starts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Amz3VEQoRNkwYHBTEJBNbf
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