Repository navigation
Commit 901a543
committed
fix(sessions): compute response boundaries before the batch append
_add_items_for_response paired a response id with its item count by
reading the full history back after the batch was appended. When that
read was cancelled or failed transiently, the batch was already durable
but the error still propagated, so the run treated a persisted turn as
failed and a retry would persist the logical turn again. The boundary
and the ever recorded flag were also left unset, and the plain save path
keeps no pending write checkpoint that could reconcile the state.
The hook now reads the count before the append and seeds the boundary as
that count plus the batch length. The mutation lock excludes every other
writer for the whole region, so the sum equals the count the read after
the append used to return. Once the append succeeds the recording is
pure assignment that cannot fail, leaving nothing that can raise between
the durable write and its bookkeeping. When the read itself fails the
append has not started, no boundary is recorded, the ever recorded flag
stays untouched, and a retry begins clean. The resumed pending write
path records boundaries through the same hook, so it follows the same
order without further changes.
The new regression persists a batch through the hook against a store
that fails every read issued after an append: the call completes, the
batch lands exactly once, the recorded boundary matches the count a read
after the append would have produced, and the compaction keyed on the
response preserves the turn persisted past it. Without the source change
the injected read failure propagates out of the hook after the durable
write.1 parent c755d21 commit 901a543
2 files changed
Lines changed: 82 additions & 1 deletion
File tree
- src/agents/memory
- tests/memory
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
559 | 569 | | |
560 | 570 | | |
| 571 | + | |
561 | 572 | | |
562 | | - | |
563 | 573 | | |
564 | 574 | | |
565 | 575 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2477 | 2477 | | |
2478 | 2478 | | |
2479 | 2479 | | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
2480 | 2551 | | |
2481 | 2552 | | |
2482 | 2553 | | |
| |||
0 commit comments