[Bug]: Claude background-only Stop treats an unconfirmed query close as successful
Before submitting
- [x] I searched existing issues and did not find a duplicate.
- [x] I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
Code-derived reproduction, not executed:
- Complete a Claude foreground turn while retaining a live query and running background work or a native subagent.
- Configure the query fixture’s
closeoperation to return immediately without ending its message stream or confirming closure. - Request thread Stop.
- Allow the query-close confirmation wait to expire after 10 seconds.
Expected behavior
If the query does not confirm closure, Stop should remain unresolved, mark the agent unresponsive, and offer Force stop.
Actual behavior
The background-only Stop path clears the live query reference after the close-confirmation timeout. It performs query-exit cleanup, terminalizes subagents, resolves the query’s closed deferred, clears background state, and returns successfully.
Unlike the foreground Stop path, it does not return ProviderAdapterInterruptTimeoutError. The unresponsive path therefore does not run.
Impact
Minor bug or occasional failure
Background work is represented as stopped without confirmed query closure, and the Stop banner does not offer Force stop. It needs a provider that doesn't confirm the stop (or the timing described above), so it is occasional rather than constant.
Version or commit
main @ 9e85538535
Environment
Claude adapter with a controlled SDK query fixture. Runtime environment not tested.
Where
- apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts:11036–11053: when no foreground turn remains, thread Stop calls
closeLiveQueryForNativeThread, resets background state, and returns. - ClaudeAdapterV2.ts:11279–11307: after the 10-second confirmation timeout, the helper clears
queryContext, finalizes query-owned work, and succeedsexisting.closed. - ClaudeAdapterV2.ts:11074–11092: the foreground path instead returns the typed interrupt-timeout error.
- apps/server/src/orchestration-v2/EffectWorker.ts:180–222: successful interruption dispatches background-work settlement; an unresponsive error takes a separate path.
Found by reading the code while porting the Stop / Force stop changes (6b1245cced, 5f2c27e706) into a fork. Derived from the code at 9e85538535; not reproduced at runtime.