Skip to content

Fix incorrect error response#50372

Closed
OmChillure wants to merge 2 commits intozed-industries:mainfrom
OmChillure:fix-error-response-max-token-reached
Closed

Fix incorrect error response#50372
OmChillure wants to merge 2 commits intozed-industries:mainfrom
OmChillure:fix-error-response-max-token-reached

Conversation

@OmChillure
Copy link
Copy Markdown
Contributor

@OmChillure OmChillure commented Feb 28, 2026

Fixes #50254

This change clarifies a misleading Agent error when generation stops due to per-response output limits.

Previously, Zed surfaced Max tokens reached, which implied the full context window (max_tokens) was exhausted. In affected cases, the actual limit was max_output_tokens for a single response.
The error now explicitly states that the output-token cap for the current response was reached, includes the limit value when available, and provides actionable guidance to send continue to resume.

Updated:

Runtime error text in ACP thread handling

Release Notes

  • Agent: Improve max token error

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 28, 2026
@OmChillure OmChillure changed the title fixed incorrect error resposne fixed incorrect error response Feb 28, 2026
@SomeoneToIgnore SomeoneToIgnore added the area:ai Related to Agent Panel, Edit Prediction, Copilot, or other AI features label Feb 28, 2026
@maxdeviant maxdeviant changed the title fixed incorrect error response Fix incorrect error response Feb 28, 2026
@zed-industries-bot
Copy link
Copy Markdown
Contributor

zed-industries-bot commented Feb 28, 2026

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against ae3bd0b

@benbrandt benbrandt force-pushed the fix-error-response-max-token-reached branch from 539ce28 to ae3bd0b Compare March 19, 2026 16:42
Copy link
Copy Markdown
Member

@benbrandt benbrandt left a comment

Choose a reason for hiding this comment

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

Cleaned it up a bit, but thanks!

@benbrandt benbrandt enabled auto-merge (squash) March 19, 2026 16:42
@benbrandt benbrandt disabled auto-merge March 19, 2026 16:42
@benbrandt benbrandt enabled auto-merge (squash) March 19, 2026 16:43
swannysec added a commit that referenced this pull request Mar 19, 2026
## Context

The permissions ceiling bug (fixed in #51948) left two open PRs (#51897,
#50372) with failed `check-size` runs. The Check Runs API requires
GitHub App auth, so we can't post passing checks from the CLI — it needs
to run inside Actions with `checks: write`.

This adds a `workflow_dispatch` workflow that takes comma-separated PR
numbers, computes sizes, applies labels, and posts passing check runs.
Delete after use.

## How to Review

- Single file: `.github/workflows/fix-size-check.yml`
- Uses the same size logic and ignored patterns as `pr-size-check.yml`
- Input is `pr_numbers` (comma-separated integers), accessed via JS API,
not shell interpolation

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
swannysec added a commit that referenced this pull request Mar 19, 2026
Both affected PRs (#51897, #50372) now have passing checks and correct
size labels. This workflow is no longer needed.
swannysec added a commit that referenced this pull request Mar 19, 2026
## Context

Cleanup of the one-off workflow added in #51958. Both affected PRs
(#51897, #50372) now have passing checks and correct size labels.

## How to Review

- Single file deletion: `.github/workflows/fix-size-check.yml`

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 20, 2026
…es#51958)

## Context

The permissions ceiling bug (fixed in zed-industries#51948) left two open PRs (zed-industries#51897,
zed-industries#50372) with failed `check-size` runs. The Check Runs API requires
GitHub App auth, so we can't post passing checks from the CLI — it needs
to run inside Actions with `checks: write`.

This adds a `workflow_dispatch` workflow that takes comma-separated PR
numbers, computes sizes, applies labels, and posts passing check runs.
Delete after use.

## How to Review

- Single file: `.github/workflows/fix-size-check.yml`
- Uses the same size logic and ignored patterns as `pr-size-check.yml`
- Input is `pr_numbers` (comma-separated integers), accessed via JS API,
not shell interpolation

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 20, 2026
## Context

Cleanup of the one-off workflow added in zed-industries#51958. Both affected PRs
(zed-industries#51897, zed-industries#50372) now have passing checks and correct size labels.

## How to Review

- Single file deletion: `.github/workflows/fix-size-check.yml`

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
toshmukhamedov pushed a commit to toshmukhamedov/zed that referenced this pull request Mar 20, 2026
…es#51958)

## Context

The permissions ceiling bug (fixed in zed-industries#51948) left two open PRs (zed-industries#51897,
zed-industries#50372) with failed `check-size` runs. The Check Runs API requires
GitHub App auth, so we can't post passing checks from the CLI — it needs
to run inside Actions with `checks: write`.

This adds a `workflow_dispatch` workflow that takes comma-separated PR
numbers, computes sizes, applies labels, and posts passing check runs.
Delete after use.

## How to Review

- Single file: `.github/workflows/fix-size-check.yml`
- Uses the same size logic and ignored patterns as `pr-size-check.yml`
- Input is `pr_numbers` (comma-separated integers), accessed via JS API,
not shell interpolation

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
toshmukhamedov pushed a commit to toshmukhamedov/zed that referenced this pull request Mar 20, 2026
## Context

Cleanup of the one-off workflow added in zed-industries#51958. Both affected PRs
(zed-industries#51897, zed-industries#50372) now have passing checks and correct size labels.

## How to Review

- Single file deletion: `.github/workflows/fix-size-check.yml`

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 23, 2026
…es#51958)

## Context

The permissions ceiling bug (fixed in zed-industries#51948) left two open PRs (zed-industries#51897,
zed-industries#50372) with failed `check-size` runs. The Check Runs API requires
GitHub App auth, so we can't post passing checks from the CLI — it needs
to run inside Actions with `checks: write`.

This adds a `workflow_dispatch` workflow that takes comma-separated PR
numbers, computes sizes, applies labels, and posts passing check runs.
Delete after use.

## How to Review

- Single file: `.github/workflows/fix-size-check.yml`
- Uses the same size logic and ignored patterns as `pr-size-check.yml`
- Input is `pr_numbers` (comma-separated integers), accessed via JS API,
not shell interpolation

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
AmaanBilwar pushed a commit to AmaanBilwar/zed that referenced this pull request Mar 23, 2026
## Context

Cleanup of the one-off workflow added in zed-industries#51958. Both affected PRs
(zed-industries#51897, zed-industries#50372) now have passing checks and correct size labels.

## How to Review

- Single file deletion: `.github/workflows/fix-size-check.yml`

## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
@OmChillure OmChillure closed this by deleting the head repository Mar 29, 2026
@bennetbo
Copy link
Copy Markdown
Member

Hey, not sure what happened with this PR. I think this change is good. Want to open a new PR @OmChillure?

@OmChillure
Copy link
Copy Markdown
Contributor Author

Hey, not sure what happened with this PR. I think this change is good. Want to open a new PR @OmChillure?

Yeah sure, opened at #52724

bennetbo added a commit that referenced this pull request 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:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the UI/UX checklist
- [ ] Tests cover the new/changed behavior
- [x] 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.

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai Related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent gets stuck and incorrectly says max tokens reached

5 participants