Handle late ACP session updates - #2262
Merged
Merged
Conversation
hallerite
marked this pull request as ready for review
August 5, 2026 22:48
mikasenghaas
previously approved these changes
Aug 5, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 93d26d7. Configure here.
hallerite
force-pushed
the
codex/fix-acp-notification-race
branch
from
August 5, 2026 23:38
93d26d7 to
b31c0e1
Compare
Contributor
ApprovabilityVerdict: Needs human review 2 blocking correctness issues found. This PR introduces new async synchronization logic and timing behavior. Unresolved review comments identify a high-severity potential race condition that could cause cross-turn data leakage, plus an unnecessary 1-second delay for tool-only turns. These substantive issues warrant human review. You can customize Macroscope's approvability policy. Learn more. |
mikasenghaas
approved these changes
Aug 6, 2026
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.

Summary
session/promptreturns without visible outputallow_empty_tool_replyRoot cause
agent-client-protocol0.11 dispatches notifications through background tasks but resolves request responses directly in the receive loop. If an agent sends its finalsession/updateimmediately before itssession/promptresponse, the prompt coroutine can resume before the update handler records the visible reply.This adds a narrowly scoped one-second compatibility grace period only when the prompt would otherwise fail for having no visible output. It can be removed after the upstream SDK provides ordered notification handling or a completion barrier.
Impact
ACP agents such as RLM no longer fail spuriously with
ACP agent produced no visible replywhen their final update races the prompt response.Validation
uv run pytest tests/v1/ -m 'not e2e'— 69 passed, 70 deselecteduv run pre-commit run --all-files— passedLive Docker/Prime ACP end-to-end tests were unavailable locally because Docker and
PRIME_API_KEYwere not configured.Note
Low Risk
Narrow compatibility wait in the ACP runner with a 1s cap; no auth or data-path changes, and existing empty-tool-turn handling is preserved.
Overview
Fixes spurious ACP agent produced no visible reply failures when
session/promptcompletes before the finalsession/updateis applied (ACP 0.11 dispatches notifications in background tasks).VerifiersACPClientnow signals anasyncio.Conditionon message and tool-call updates. Afterconnection.promptreturns, if there is still no visible text, the runner waits up to 1 second for a late text chunk (tool-only updates do not count as a reply).allow_empty_tool_replybehavior is unchanged.The ACP resume e2e test no longer requires
trace.tools; it documents that native MCP tools may not appear on intercepted model requests and that the ACP transcript is authoritative.Reviewed by Cursor Bugbot for commit b31c0e1. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Handle late ACP session updates by waiting up to 1 second for visible text
LATE_UPDATE_GRACE_SECONDS(1.0s) bounded wait in thepromptfunction in runner.py after receiving the initial response, allowing late-arriving visible text dispatched in background tasks to be collected before deciding the agent produced no reply.asyncio.Condition(output_changed) onVerifiersACPClientsosession_updatecan notify waiters when new visible text or tool calls arrive.test_acp_resume_with_toolassertion in test_e2e.py to no longer requiretrace.toolsto be non-empty, relying on the ACP transcript as the source of truth instead.promptnow waits up to 1 second longer per call when no visible reply has been received yet, reducing prematureRuntimeErrorfor valid late replies.📊 Macroscope summarized b31c0e1. 1 file reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.