Repository navigation
Commit a19e156
committed
fix(agents): ensure wrapAnthropicStreamWithRecovery works with async streamFn
Previously, when agent.streamFn returns a Promise (async function), the recovery
wrapper only caught Promise rejections but did NOT pump the resolved stream to
detect mid-stream error events like Anthropic's "Invalid signature in thinking block".
This caused recovery to fail silently for async streams.
The fix unifies sync and async handling:
- Always create an outer stream for consistent event pumping
- Await the inner stream (if it's a Promise) to get the actual stream
- Pump the resolved stream through pumpStreamWithRecovery to catch mid-stream errors
- Handle initial Promise rejection by retrying with cleaned messages
- Removed unused wrapRetryStreamWithRecoveryNotification helper
This ensures Anthropic thinking signature recovery works correctly regardless of
whether the embedded agent's streamFn is sync or async.
Fixes #954291 parent c47cd52 commit a19e156
2 files changed
Lines changed: 27 additions & 48 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
602 | 602 | | |
603 | 603 | | |
604 | 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 | 605 | | |
634 | 606 | | |
635 | 607 | | |
| |||
724 | 696 | | |
725 | 697 | | |
726 | 698 | | |
727 | | - | |
728 | | - | |
729 | | - | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
730 | 712 | | |
731 | 713 | | |
732 | 714 | | |
733 | 715 | | |
734 | 716 | | |
735 | 717 | | |
736 | 718 | | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
747 | | - | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
748 | 724 | | |
749 | 725 | | |
| 726 | + | |
750 | 727 | | |
751 | 728 | | |
752 | 729 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4480 | 4480 | | |
4481 | 4481 | | |
4482 | 4482 | | |
4483 | | - | |
| 4483 | + | |
4484 | 4484 | | |
4485 | 4485 | | |
4486 | 4486 | | |
| |||
4498 | 4498 | | |
4499 | 4499 | | |
4500 | 4500 | | |
4501 | | - | |
| 4501 | + | |
| 4502 | + | |
4502 | 4503 | | |
4503 | 4504 | | |
4504 | 4505 | | |
| |||
4516 | 4517 | | |
4517 | 4518 | | |
4518 | 4519 | | |
4519 | | - | |
4520 | | - | |
| 4520 | + | |
| 4521 | + | |
| 4522 | + | |
4521 | 4523 | | |
4522 | 4524 | | |
4523 | 4525 | | |
| |||
4530 | 4532 | | |
4531 | 4533 | | |
4532 | 4534 | | |
4533 | | - | |
| 4535 | + | |
4534 | 4536 | | |
4535 | 4537 | | |
4536 | 4538 | | |
| |||
4551 | 4553 | | |
4552 | 4554 | | |
4553 | 4555 | | |
4554 | | - | |
| 4556 | + | |
4555 | 4557 | | |
4556 | 4558 | | |
4557 | 4559 | | |
| |||
0 commit comments