Skip to content

acp_thread: Clarify max token limit error message#52724

Merged
bennetbo merged 5 commits intozed-industries:mainfrom
OmChillure:fix-max-token-error-message
Mar 30, 2026
Merged

acp_thread: Clarify max token limit error message#52724
bennetbo merged 5 commits intozed-industries:mainfrom
OmChillure:fix-max-token-error-message

Conversation

@OmChillure
Copy link
Copy Markdown
Contributor

@OmChillure OmChillure commented Mar 30, 2026

When generation stops due to the per-response output limit, Zed was surfacing "Max tokens reached", which implies the full context window was exhausted. In reality, max_output_tokens (the per-response cap) may have been hit a different condition.

This change distinguishes between the two cases: if output_tokens >= max_output_tokens, it surfaces "Maximum output tokens reached"; otherwise it falls back to "Maximum tokens reached".

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #50254

Note : Reopens #50372 suggested by @bennetbo

Release Notes:

  • Fixed misleading "Max tokens reached" error by distinguishing between per-response output token limit and total context window limit.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 30, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator bot requested review from a team, mikayla-maki and osyvokon and removed request for a team March 30, 2026 11:47
@zed-community-bot zed-community-bot bot added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Mar 30, 2026
Copy link
Copy Markdown
Member

@bennetbo bennetbo left a comment

Choose a reason for hiding this comment

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

Pushed a change that also adjusts the logging message. Thank you!

@OmChillure
Copy link
Copy Markdown
Contributor Author

OmChillure commented Mar 30, 2026

Pushed a change that also adjusts the logging message. Thank you!

ohh sorry !
thank you

@bennetbo bennetbo enabled auto-merge (squash) March 30, 2026 12:33
@OmChillure
Copy link
Copy Markdown
Contributor Author

OmChillure commented Mar 30, 2026

Hey @bennetbo , the tests need to be update.

Some more tests failing though, its not regarding our change but somehting regarding audio

logs


-> cargo test -p agent_ui test_max_tokens_error_is_rendered
   Compiling agent_ui v0.1.0 (/media/omchillure/Projects/zed-oss/zed/crates/agent_ui)
error[E0433]: failed to resolve: use of undeclared type `Audio`
    --> crates/agent_ui/src/conversation_view.rs:2321:13
     |
2321 |             Audio::play_sound(Sound::AgentDone, cx);
     |             ^^^^^ use of undeclared type `Audio`
     |
help: there is an enum variant `agent_client_protocol::ContentBlock::Audio` and 4 others; try using the variant's enum
     |
2321 -             Audio::play_sound(Sound::AgentDone, cx);
2321 +             agent_client_protocol::ContentBlock::play_sound(Sound::AgentDone, cx);
     |
2321 -             Audio::play_sound(Sound::AgentDone, cx);
2321 +             context_server::types::MessageContent::play_sound(Sound::AgentDone, cx);
     |
2321 -             Audio::play_sound(Sound::AgentDone, cx);
2321 +             context_server::types::ToolResponseContent::play_sound(Sound::AgentDone, cx);
     |
2321 -             Audio::play_sound(Sound::AgentDone, cx);
2321 +             crate::acp::ContentBlock::play_sound(Sound::AgentDone, cx);
     |

error[E0433]: failed to resolve: use of undeclared type `Sound`
    --> crates/agent_ui/src/conversation_view.rs:2321:31
     |
2321 |             Audio::play_sound(Sound::AgentDone, cx);
     |                               ^^^^^ use of undeclared type `Sound`
     |
help: there is an enum variant `time::util::local_offset::Soundness::Sound`; try using the variant's enum
     |
2321 -             Audio::play_sound(Sound::AgentDone, cx);
2321 +             Audio::play_sound(time::util::local_offset::Soundness::AgentDone, cx);
     |

For more information about this error, try `rustc --explain E0433`.
error: could not compile `agent_ui` (lib test) due to 2 previous errors

auto-merge was automatically disabled March 30, 2026 12:45

Pull Request is not mergeable

@bennetbo bennetbo enabled auto-merge (squash) March 30, 2026 12:58
@bennetbo bennetbo merged commit f18c963 into zed-industries:main Mar 30, 2026
30 checks passed
@zed-zippy zed-zippy bot added the PR state:needs review Used to label PRs that are in need of a post-merge approval label Apr 6, 2026
@MrSubidubi MrSubidubi removed the PR state:needs review Used to label PRs that are in need of a post-merge approval label Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent gets stuck and incorrectly says max tokens reached

5 participants