Commit e94cade
fix(realtime): keep conversation order when updateHistory corrects or inserts an item
`conversation.item.create` appends to the end of the conversation when
`previous_item_id` is omitted. `resetHistory()` omitted it for every item it
created, so correcting an item in the middle of the history -- which the voice
agent guide recommends for exactly that purpose -- moved it behind everything
that followed it. Inserting an item did the same.
The items are now walked in new-history order so each created item can name the
item it follows. Untouched items keep their place and can anchor the next
insert; a function call that could not be created does not, and neither does a
removed item.
An item with nothing before it is still created without `previous_item_id`.
The protocol accepts `previous_item_id: null` but does not document where that
places the item, so this leaves that case exactly as it was.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent eb690a4 commit e94cade
3 files changed
Lines changed: 134 additions & 9 deletions
File tree
- .changeset
- packages/agents-realtime
- src
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
993 | 993 | | |
994 | 994 | | |
995 | 995 | | |
996 | | - | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
997 | 1011 | | |
998 | | - | |
999 | | - | |
| 1012 | + | |
1000 | 1013 | | |
1001 | 1014 | | |
1002 | | - | |
1003 | | - | |
1004 | | - | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
1005 | 1018 | | |
1006 | | - | |
1007 | | - | |
| 1019 | + | |
| 1020 | + | |
1008 | 1021 | | |
1009 | 1022 | | |
1010 | 1023 | | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
1011 | 1030 | | |
1012 | 1031 | | |
1013 | | - | |
| 1032 | + | |
| 1033 | + | |
1014 | 1034 | | |
1015 | 1035 | | |
1016 | 1036 | | |
| 1037 | + | |
1017 | 1038 | | |
1018 | 1039 | | |
1019 | 1040 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
586 | 586 | | |
587 | 587 | | |
588 | 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 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
589 | 688 | | |
590 | 689 | | |
591 | 690 | | |
| |||
0 commit comments