Commit 7bb5911
fix: Wire CircuitBreaker and FailoverManager into execution paths (#1539)
* fix: Wire CircuitBreaker and FailoverManager into execution paths (fixes #1535)
- Add FailoverManager integration to LLM._call_with_retry() and _call_with_retry_async()
* New failover_manager parameter in LLM constructor
* _switch_to_profile() method for switching auth profiles
* Mark success/failure and automatic profile switching on retries
- Add CircuitBreaker integration to tool execution in AgentToolExecution
* _execute_tool_with_circuit_breaker() wrapper method
* 5-failure threshold, 60s recovery timeout, graceful degradation
* Per-tool circuit breakers prevent cascading failures
Both components were fully implemented but never called from execution paths.
Now users who configure them get actual resilience protection.
Co-authored-by: MervinPraison <MervinPraison@users.noreply.github.com>
* fix: Address critical bugs in CircuitBreaker and FailoverManager implementation
- Fix FailoverManager initialization: properly initialize _current_profile
- Fix CircuitBreaker failure detection: convert error dicts to exceptions
- Fix profile switching: update in-flight request parameters in retry loop
- Add proper typing with FailoverManagerProtocol instead of Any
- Fix import handling to prevent NameError on CircuitBreakerException
- Add agent/session context to circuit breaker error returns
- Allow failover on non-retryable provider failures (bad credentials, etc)
Addresses critical P1 issues identified by Greptile and CodeRabbit reviews.
Makes FailoverManager and CircuitBreaker actually functional end-to-end.
Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
---------
Co-authored-by: praisonai-triage-agent[bot] <272766704+praisonai-triage-agent[bot]@users.noreply.github.com>
Co-authored-by: MervinPraison <MervinPraison@users.noreply.github.com>1 parent 4faf056 commit 7bb5911
2 files changed
Lines changed: 168 additions & 13 deletions
Lines changed: 69 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
| 205 | + | |
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
| 222 | + | |
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| |||
594 | 594 | | |
595 | 595 | | |
596 | 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 | + | |
597 | 664 | | |
598 | 665 | | |
599 | 666 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
14 | 20 | | |
15 | 21 | | |
16 | 22 | | |
| |||
354 | 360 | | |
355 | 361 | | |
356 | 362 | | |
| 363 | + | |
357 | 364 | | |
358 | 365 | | |
359 | 366 | | |
| |||
429 | 436 | | |
430 | 437 | | |
431 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
432 | 447 | | |
433 | 448 | | |
434 | 449 | | |
| |||
685 | 700 | | |
686 | 701 | | |
687 | 702 | | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
688 | 718 | | |
689 | | - | |
| 719 | + | |
690 | 720 | | |
691 | 721 | | |
692 | 722 | | |
| |||
707 | 737 | | |
708 | 738 | | |
709 | 739 | | |
710 | | - | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
711 | 747 | | |
712 | 748 | | |
713 | 749 | | |
714 | | - | |
715 | | - | |
716 | | - | |
| 750 | + | |
717 | 751 | | |
718 | 752 | | |
719 | 753 | | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
720 | 779 | | |
721 | 780 | | |
722 | 781 | | |
| |||
746 | 805 | | |
747 | 806 | | |
748 | 807 | | |
749 | | - | |
| 808 | + | |
750 | 809 | | |
751 | 810 | | |
752 | 811 | | |
| |||
767 | 826 | | |
768 | 827 | | |
769 | 828 | | |
770 | | - | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
771 | 836 | | |
772 | 837 | | |
773 | 838 | | |
774 | | - | |
775 | | - | |
776 | | - | |
| 839 | + | |
777 | 840 | | |
778 | 841 | | |
779 | 842 | | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
780 | 868 | | |
781 | 869 | | |
782 | 870 | | |
| |||
0 commit comments