Propagate agent session hydration cancellation - #328342
Draft
Rob Lourens (roblourens) wants to merge 2 commits into
Draft
Propagate agent session hydration cancellation#328342Rob Lourens (roblourens) wants to merge 2 commits into
Rob Lourens (roblourens) wants to merge 2 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR improves cancellation behavior during agent session hydration so cancelled loads fail fast and don’t get converted into empty chat sessions, and it adds regression coverage for cancellation followed by a successful retry.
Changes:
- Propagate cancellation by rejecting hydration waits with a cancellation error.
- Avoid swallowing cancellation errors during subscription so callers can abort cleanly.
- Add a regression test covering cancellation and subsequent retry.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts | Changes hydration/cancellation semantics to reject on cancellation and rethrow cancellation errors. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts | Adds a regression test ensuring cancellation rejects and retry works after a delayed subscription error. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
Comment on lines
+3587
to
+3603
| test('cancelling session hydration rejects without creating an empty session', async () => { | ||
| const sessionResource = URI.from({ scheme: 'agent-host-copilot', path: '/cancelled-hydration' }); | ||
| const backendSession = AgentSession.uri('copilot', 'cancelled-hydration'); | ||
| const { sessionHandler, agentHostService } = createContribution(disposables); | ||
| agentHostService.makePendingErrorSub(backendSession.toString()); | ||
|
|
||
| const cancellation = disposables.add(new CancellationTokenSource()); | ||
| const loadPromise = sessionHandler.provideChatSessionContent(sessionResource, cancellation.token); | ||
| cancellation.cancel(); | ||
|
|
||
| await assert.rejects(loadPromise, isCancellationError); | ||
|
|
||
| agentHostService.firePendingSubError(backendSession.toString(), new Error('Delayed subscription failed')); | ||
| const retriedSession = await sessionHandler.provideChatSessionContent(sessionResource, CancellationToken.None); | ||
| disposables.add(toDisposable(() => retriedSession.dispose())); | ||
| assert.deepStrictEqual(retriedSession.history, []); | ||
| }); |
Comment on lines
5227
to
5231
| /** | ||
| * Resolves once a subscription has received its first snapshot (its | ||
| * `value` is no longer `undefined`) — i.e. it has hydrated with state or | ||
| * an error. Resolves immediately if already hydrated or if cancellation | ||
| * is requested. | ||
| * an error. Rejects with a cancellation error if cancellation is requested. | ||
| */ |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Validation
(Written by Copilot)