Skip to content

Comments

Fix: aborted steering prompt incorrectly terminates agent response#297020

Merged
connor4312 merged 3 commits intomainfrom
copilot/fix-aborted-steering-prompt
Feb 23, 2026
Merged

Fix: aborted steering prompt incorrectly terminates agent response#297020
connor4312 merged 3 commits intomainfrom
copilot/fix-aborted-steering-prompt

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

Cancelling a pending steering prompt left yieldRequested permanently set to true, causing the in-flight agent response to terminate early even though no steering prompt would ever be delivered.

The autorun in chatServiceImpl.ts only propagated yieldRequested = true to the extension host but never propagated the reset back to false. This meant that even when yieldRequested was reset on CancellableRequest, the extension host's in-flight request still saw yieldRequested = true and terminated the response.

Changes

  • CancellableRequest: Added resetYieldRequested() to set _yieldRequested back to false
  • ChatService.removePendingRequest: After removing a request from the model, checks whether any steering requests remain in the queue; if none do, calls resetYieldRequested() on the active pending request
  • setYieldRequested chain: Changed setYieldRequested throughout the entire call chain (IChatAgentImplementationIChatAgentServicemainThreadChatAgents2extHost.protocolextHostChatAgents2) to accept a value: boolean parameter
  • chatServiceImpl.ts autorun: Updated to always call setYieldRequested with the current value (both true and false), so when a steering prompt is cancelled and yieldRequested resets to false, the reset is propagated all the way to the extension host's in-flight request
Original prompt

This section details on the original issue you should resolve

<issue_title>Steering prompt which is aborted still results in the agent terminating their response</issue_title>
<issue_description>> Be in the middle of writing an askQuestions response

'Accidentally' submit a steering prompt and have it pending
Cancel the steering prompt
Submit response to askQuestions tool
Expect a response from copilot, instead get nothing but a terminated response

Impact: unexpected end of copilot response.</issue_description>

<agent_instructions>yieldRequested should go back to false in this case</agent_instructions>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…m queue

Co-authored-by: connor4312 <2230985+connor4312@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix agent termination response on aborted steering prompt Fix: aborted steering prompt incorrectly terminates agent response Feb 23, 2026
@connor4312
Copy link
Member

@copilot pendingRequest.yieldRequested.read only handles it being true and doesn't set the extension host request back to false

…rompt is aborted

Co-authored-by: connor4312 <2230985+connor4312@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 23, 2026

@copilot pendingRequest.yieldRequested.read only handles it being true and doesn't set the extension host request back to false

Fixed in 41cae3f. Changed setYieldRequested through the entire chain (IChatAgentImplementationIChatAgentServicemainThreadChatAgents2extHost.protocolextHostChatAgents2) to accept a value: boolean parameter. The autorun now always calls setYieldRequested with the current value (both true and false), so when the steering prompt is cancelled and yieldRequested resets to false, that reset is also propagated to the extension host's in-flight request.

@connor4312 connor4312 marked this pull request as ready for review February 23, 2026 18:10
Copilot AI review requested due to automatic review settings February 23, 2026 18:10
@connor4312 connor4312 enabled auto-merge (squash) February 23, 2026 18:10
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 23, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an issue in the chat agent “steering prompt” flow where cancelling a pending steering prompt could leave yieldRequested stuck as true, causing an in-flight agent response to terminate early even though no steering prompt would be delivered.

Changes:

  • Add resetYieldRequested() on the in-flight CancellableRequest and invoke it when the last pending steering request is removed.
  • Change the setYieldRequested plumbing end-to-end (workbench → main thread → ext host) to accept an explicit value: boolean and propagate both true and false.
  • Update affected tests/mocks to match the new method signature.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/common/voiceChatService.test.ts Updates test doubles to match the new setYieldRequested(requestId, value) signature.
src/vs/workbench/contrib/chat/test/common/chatService/chatService.test.ts Updates the agent stub signature used by the steering/yield test.
src/vs/workbench/contrib/chat/common/participants/chatAgents.ts Updates public/internal interfaces and forwarding (IChatAgentImplementation / IChatAgentService) to pass a boolean value.
src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts Implements yield reset and ensures the autorun propagates yield state updates (true and false) to the agent service.
src/vs/workbench/api/common/extHostChatAgents2.ts Updates $setYieldRequested to accept and apply the boolean value to the in-flight request.
src/vs/workbench/api/common/extHost.protocol.ts Updates the ext host shape contract to $setYieldRequested(requestId, value).
src/vs/workbench/api/browser/mainThreadChatAgents2.ts Forwards the new setYieldRequested(requestId, value) call across the main thread ↔ ext host boundary.

Comment on lines 432 to 446
test('steering message queued triggers setYieldRequested', async () => {
const requestStarted = new DeferredPromise<void>();
const completeRequest = new DeferredPromise<void>();
let setYieldRequestedCalled = false;

const slowAgent: IChatAgentImplementation = {
async invoke(request, progress, history, token) {
requestStarted.complete();
await completeRequest.p;
return {};
},
setYieldRequested(requestId: string) {
setYieldRequested(requestId: string, value: boolean) {
setYieldRequestedCalled = true;
},
};
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

This test now risks a false positive: ChatService propagates yieldRequested both when it becomes true and when it is false (including the initial false), so setYieldRequestedCalled may be set during request startup even if queueing a steering request never toggles it to true. Consider capturing the boolean value passed to setYieldRequested and asserting the transition to true happens only after the steering request is queued (and ideally add an assertion that it returns to false when the steering request is removed/cancelled).

Copilot uses AI. Check for mistakes.
@connor4312 connor4312 merged commit ac609e0 into main Feb 23, 2026
24 checks passed
@connor4312 connor4312 deleted the copilot/fix-aborted-steering-prompt branch February 23, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Steering prompt which is aborted still results in the agent terminating their response

3 participants