Copilot Agent Mode can stream stale previous-task response under a new user turn after cancel/resend
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
Type: Bug
## Summary
In VS Code Copilot Agent Mode / Copilot CLI, a new user turn can be accepted by the Agent Host with the correct user text, but the streamed assistant response belongs to stale previous task context. The agent appeared not to see the current question and answered a previous Copilot task instead.
This looks like a turn/session desynchronization after cancel/resend while the previous agent work was still active: `chat/turnStarted` has the correct payload and new `turnId`, but subsequent `chat/delta` / response parts are from the prior task.
## Environment
- VS Code: Stable server versions present on Remote SSH host: 1.129.1 (`8a7abeba6e03ea3af87bfbce9a1b7e48fed567b8`), 1.129.0, 1.128.1
- Remote host: Linux x86_64 via VS Code Remote SSH
- Agent provider: `copilotcli` / Copilot Agent Mode
- Agent Host transport in AHP log: websocket
- Model selected in the session: GPT-5.5
- AHP JSONL logging was enabled on the remote host
## What happened
A Copilot chat session was working on an older task about Hassio prompt/runtime behavior. I then sent a new question asking about a Drawbot test failure:
```text
> `drawbot` separately failed `0.75` on continuity case
what failed there? which scenario?
```
The UI showed this new message bubble, but the assistant answered about the older Hassio restart/prompt-tail task instead. A follow-up asking whether it saw the new question also did not recover the correct context.
## Evidence from AHP/session logs
Target session:
```text
copilotcli:/5e1bc28d-982a-4471-a292-244753981956
```
AHP wire log shows the correct new user payload was sent to the target chat channel:
```text
2026-07-20T11:08:22.637Z c2s dispatchAction chat/turnStarted
turnId=request_b7fb7e83-999f-4031-b5c1-1411c3d4f22b
message.text="> `drawbot` separately failed `0.75` on continuity case\r\n\r\nwhat failed there? which scenario?"
```
That first turn was cancelled:
```text
2026-07-20T11:08:42.148Z c2s dispatchAction chat/turnCancelled
turnId=request_b7fb7e83-999f-4031-b5c1-1411c3d4f22b
```
Then the same correct payload was sent again:
```text
2026-07-20T11:08:44.074Z c2s dispatchAction chat/turnStarted
turnId=request_8cd7ee1d-cbed-4a9f-a885-26e4a79d6dff
message.text="> `drawbot` separately failed `0.75` on continuity case\r\n\r\nwhat failed there? which scenario?"
```
The host acknowledged/echoed the same `chat/turnStarted` back server-to-client, and then streamed hundreds of `chat/delta` events for that new turn:
```text
request_8cd7ee1d... | s2c action chat/delta | 503 events
request_8cd7ee1d... | s2c action chat/turnComplete | 1 event
```
However, reconstructing the streamed markdown for that second turn shows the assistant answered stale previous context, not the Drawbot question. It discussed a Hassio restart and prompt/nudge layer, e.g.:
```text
Found not mysticism, but nasty timing: your restart happened, but it was before the final changes...
...
You are right — I messed up and went into "let me restart it", although you asked something else: why after your reboot it still appeared...
```
The session event log for the target session also did not contain this Drawbot payload as a normal `user.message`; its last user message was still the earlier prompt-tail/emoji task. That suggests the UI/Agent Host accepted and displayed the new turn while the actual runner context/output remained tied to previous work.
## Expected
When `chat/turnStarted` is accepted with a new `turnId` and `message.text`, the agent runner should receive that exact user message as the active input, and streamed response parts for that `turnId` should answer that input.
If a previous turn is still running or cancellation is incomplete, the new turn should either be queued safely, rejected, or clearly blocked until the previous runner state is closed. It should not stream stale previous-task output under the new user bubble/turn id.
## Actual
The correct new Drawbot payload was visible in `chat/turnStarted` and echoed by the host, but the streamed answer under the new turn was from older Hassio prompt/restart context. From the user perspective, Agent Mode ignored the current question and answered a previous prompt.
## Repro shape
I do not have a minimal clean repro yet, but the observed sequence was:
1. Have an Agent Mode / Copilot CLI session doing multi-step tool work.
2. Send a new user question while the previous work/turn state is still active or recently active.
3. Cancel the first attempt shortly after it begins.
4. Resend the same new question.
5. Observe that the chat UI shows the new user bubble, but the streamed assistant response is from stale previous task context.
## Why this is high impact
This is not just a bad model answer. It breaks the integrity contract between the visible user message and the actual runner input/output. For coding agents this is dangerous because the assistant can keep editing/running tools for the wrong task while the UI indicates it is responding to the latest user request.
Contributor guide
Assessment
This issue has not been assessed yet.