Commit e4ed37f
authored
fix(agent-core-v2): adopt the replayed turn outcome on restore (#215)
## Related Issue
Follow-up to #213, from the review discussion on
`reconcileAfterRestore`.
## Problem
`SessionOutcomeMirror` persists the last turn outcome (`completed` /
`failed` / `cancelled`) into the session metadata. On restore it only
reconciled one stale case: a persisted outcome with no ended turn on the
replayed wire. If the persisted value itself went stale — the async
metadata write never landed before shutdown — a session whose last turn
had actually completed still resumed showing "manually stopped" (or a
failed badge), because the replayed wire had an ended turn and the
reconcile kept whatever was on disk.
## What changed
- `sessionOutcomeMirrorService.ts`: after restore, when the replayed
`lastEnded` reason is unambiguous, adopt it with `touchUpdatedAt: false`
and track its turn id for the undo range check: `completed` →
`completed`, `failed` / `blocked` → `failed`. A replayed `cancelled` is
deliberately left alone: the wire carries no `interruptReason`, so it
cannot distinguish a user stop from a programmatic abort, and only user
stops are ever persisted.
- Tests: stale `cancelled` replaced by replayed `completed`; replayed
`blocked` maps to `failed`; replayed `cancelled` keeps the persisted
`completed`; the adopted turn id feeds the undo range check.
## Verification
- `pnpm --filter @pymodel/agent-core-v2 exec vitest run` — 347 files,
5,723 tests passed
- `typecheck`, `tsgo`, `lint:imports`, `check-no-comments`, oxlint on
the changed files — all exit 0
## Checklist
- [x] I have read the
[CONTRIBUTING](https://github.com/PyModel/pythinker-code/blob/main/CONTRIBUTING.md)
document.
- [x] I have linked a related issue (external PRs: the issue must have a
maintainer's `/approve`).
- [x] I have added tests that prove my feature works.
- [x] Ran `gen-changesets` skill, or this PR needs no changeset.
- [x] Ran `gen-docs` skill, or this PR needs no doc update.1 parent 0753f13 commit e4ed37f
3 files changed
Lines changed: 89 additions & 0 deletions
File tree
- .changeset
- packages/agent-core-v2
- src/session/sessionActivity
- test/session/sessionActivity
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
132 | 137 | | |
133 | 138 | | |
134 | 139 | | |
| |||
164 | 169 | | |
165 | 170 | | |
166 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
374 | 447 | | |
375 | 448 | | |
376 | 449 | | |
| |||
0 commit comments