Commit cd6804d
agentHost: implement Claude truncateSession (Phase 6.7 — Restore Checkpoint + Start Over) (#323197)
* agentHost: implement Claude truncateSession (Phase 6.7 — Restore Checkpoint + Start Over)
Implements IAgent.truncateSession for the Claude agent host so the
workbench "Restore Checkpoint" and "Start Over" actions work end-to-end:
- Point-restore (turnId): truncates the conversation in place on the same
SDK session id / protocol URI via the SDK's `resumeSessionAt` option. The
protocol turn is resolved to its SDK assistant-envelope uuid and staged as
a one-shot anchor the next turn's rebuild applies (lazy — full history is
preserved if the user restores then walks away).
- Remove-all (no turnId, "Start Over"): tears down the live subprocess,
deletes the on-disk transcript, and recreates a fresh provisional under the
same id, preserving the model/agent/permissionMode overlay.
Teardown awaits the subprocess's actual exit (Query.return() -> the SDK's
memoized cleanup -> transport.waitForExit()) before deleting + respawning the
same `--session-id`, fixing a "Session ID ... is already in use" race. Also
fixes a pre-existing rebind consumer-loop handoff race surfaced by truncation
(post-restore turn could hang), and simplifies the pipeline's query handles
(single `_query` mirroring the warm subprocess; `_needsRebind` as the sole
health signal).
Unit + integration green (427 Claude tests); both flows live-E2E verified
against real Claude. See node/claude/phase6.7-plan.md for the implementation
log and node/claude/roadmap.md (Phase 6.7) marked done.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* agentHost: address Phase 6.7 PR review
- claudeAgentSession: retain the pending truncation anchor until a rebuild
succeeds (read it without clearing, clear only after materialize / rebuild
installs the pipeline). A throw/cancel after reading no longer silently
drops `resumeSessionAt`, so the next send retries the checkpoint restore.
+ regression test.
- claudeSdkPipeline: `_ensureQueryBound` now honors `_needsRebind` (rebuilds
via the rematerializer like `send()` does) so pre-flight helpers
(reloadPlugins / snapshotResolvedCustomizations) never operate on a dead
stream after an abort/crash.
- claudeAgent: cold remove-all fails fast when no working directory is
available (SDK cwd absent and no live session), mirroring `_resumeSession`
and the fork path, instead of recreating a provisional that fails later.
- claudeSdkPipeline: pass the error object to the logger in shutdownAndWait
instead of stringifying it, preserving stack traces.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent a646e32 commit cd6804d
13 files changed
Lines changed: 1242 additions & 40 deletions
File tree
- src/vs/platform/agentHost
- node/claude
- test
- common
- node
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
581 | 671 | | |
582 | 672 | | |
583 | 673 | | |
| |||
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| |||
167 | 169 | | |
168 | 170 | | |
169 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
170 | 177 | | |
171 | 178 | | |
172 | 179 | | |
| |||
Lines changed: 71 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
298 | 345 | | |
299 | 346 | | |
300 | 347 | | |
| |||
330 | 377 | | |
331 | 378 | | |
332 | 379 | | |
| 380 | + | |
333 | 381 | | |
334 | 382 | | |
335 | 383 | | |
| |||
369 | 417 | | |
370 | 418 | | |
371 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
372 | 424 | | |
373 | 425 | | |
374 | 426 | | |
| |||
421 | 473 | | |
422 | 474 | | |
423 | 475 | | |
| 476 | + | |
424 | 477 | | |
425 | 478 | | |
426 | 479 | | |
| |||
432 | 485 | | |
433 | 486 | | |
434 | 487 | | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
435 | 493 | | |
436 | 494 | | |
437 | 495 | | |
| |||
506 | 564 | | |
507 | 565 | | |
508 | 566 | | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
509 | 578 | | |
510 | 579 | | |
511 | 580 | | |
| |||
545 | 614 | | |
546 | 615 | | |
547 | 616 | | |
548 | | - | |
| 617 | + | |
549 | 618 | | |
550 | 619 | | |
551 | 620 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
36 | 46 | | |
37 | 47 | | |
38 | 48 | | |
| |||
122 | 132 | | |
123 | 133 | | |
124 | 134 | | |
125 | | - | |
| 135 | + | |
126 | 136 | | |
127 | 137 | | |
128 | 138 | | |
| |||
0 commit comments