Commit 98d56c0
committed
fix local codex review comment
- [P1] Prevent duplicating run items on approval resume — packages/agents-core/src/runImplementation.ts:460-462
When we resume a turn after tool approval, originalPreStepItems already contains the assistant message/tool-call items that were generated before the interruption.
Initializing newItems with processedResponse.newItems reuses those same instances, so SingleStepResult.generatedItems ends up concatenating [...preStepItems, ...newItems] where
the message/tool-call appear twice. This causes duplicate entries to be persisted in session history and re-emitted to callers every time an approval is resolved. The previous
implementation started from the tool results only (const newItems = functionResults.map(...)) to avoid this duplication. We should revert to building newItems from the newly
produced tool results instead of cloning the prior processedResponse.newItems array.1 parent 6c57d2a commit 98d56c0
File tree
2 files changed
+68
-3
lines changed- packages/agents-core
- src
- test
2 files changed
+68
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
460 | | - | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
461 | 473 | | |
462 | 474 | | |
463 | 475 | | |
| |||
474 | 486 | | |
475 | 487 | | |
476 | 488 | | |
477 | | - | |
478 | | - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
479 | 495 | | |
480 | 496 | | |
481 | 497 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1744 | 1744 | | |
1745 | 1745 | | |
1746 | 1746 | | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
1747 | 1796 | | |
1748 | 1797 | | |
1749 | 1798 | | |
| |||
0 commit comments