Repository navigation
Description
Claude Opus 5.5 on behalf of SouthCarpet
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Open a thread whose project has an open GitHub pull request, and link the pull request to the thread.
- In one turn, ask the agent to settle this thread and then watch the pull request. The agent calls
t3_thread_organizewithaction: "settle"; the tool returns{ "settlesWhenTurnEnds": true }. - In the same turn the agent calls
watch_pull_requestfor that pull request; the tool returnswatching: true. - Let the turn finish, then open the thread details.
I reproduced this with a focused test, not with a live agent run. On upstream main 220eb73524 the test calls the real MCP handlers as the thread's own agent: first t3_thread_organize with action: "settle", then watch_pull_request. Settle returned { settlesWhenTurnEnds: true }; watch returned watching: true and wasWatching: false. Before the run completed, the thread was not settled and the watch was present. After I wrote a run-completed event and awaited thread.settled, the thread was settled and the watch was gone (the pull request link stayed). Project lookup and the guide service are test fakes; the handlers, ThreadManagementService, the orchestrator and the in-memory store are real. Reversing the two calls (watch, then settle) also ends the watch, which matches the docs.
Expected behavior
The agent was told watching: true and to end its turn, so it expects to be woken on failed checks, comments or conflicts. One of these should be true:
- A watch turned on after the settle request keeps the thread active, or cancels the pending settle.
- Or
watch_pull_requestsays that the thread settles at the end of the turn and that this will end the watch.
I do not know which one you prefer.
Actual behavior
At the end of the turn the deferred settle runs and clears the watch. No error or notice reaches the agent. Because the watch sweep selects only links that have a watch (apps/server/src/orchestration-v2/PullRequestWatchReactor.ts:556-563), I expect the agent is never woken; the test shows only that the watch is removed.
Code path on main 220eb73524:
apps/server/src/mcp/toolkits/thread/handlers.ts:296-303andapps/server/src/orchestration-v2/ThreadManagementService.ts:962-972forksettleAfterRunand returnsettlesWhenTurnEnds.ThreadManagementService.ts:950-959waits for the run and dispatchesthread.settle. It does not check for a watch added after the request.apps/server/src/orchestration-v2/Orchestrator.ts:3254clears every watch inthread.settle.apps/server/src/mcp/toolkits/pullRequests/handlers.ts:262-300returnswatching: truewhile the settle is still pending.
docs/user/source-control.md:295 says settling ends all watches of the thread. This report is only about the order: a watch turned on after the settle request.
Impact
Minor bug or occasional failure
Version or commit
Upstream main 220eb73524 (test reproduction); first seen in code on nightly 0.1.3-nightly.20261026.3726 (3f9448747b).
Environment
Windows 11, focused vitest run in a worktree of main (Node 25.8.1; the repository declares 26.12.1). No live agent run.
Workaround
Turn on the watch first, or settle in a separate turn after the watch has ended. Or unsettle the thread and ask the agent to watch again.
Related
- [Bug]: Agent self-snooze is overridden when the same run completes #18985 (agent self-snooze overridden when the same run completes; fixed by fix(threads): preserve snooze when an existing run completes #17118): same class.
- fix(server): an agent can settle its own thread when its turn ends #17145 added settle at turn end.
- feat(threads): file working threads and settle quietly when idle #18606 (open) replaces the waiter with a stored intent. Its test covers the order watch, then settle, and says settling ends the watch. It does not cover this order.
- fix(server): an agent can mark its own thread unread when its turn ends #24157 (open) changes the same self-settle code.
Activity