Commit a011714
Enhance tool calling: support multi-step orchestration with loop detection
This commit improves the original PR oracle#50 fix by replacing the overly
restrictive single-tool limitation with intelligent multi-step support.
Changes:
- Add `max_sequential_tool_calls` parameter (default: 8) to OCIGenAIBase
- Implement intelligent loop detection algorithm that identifies when
the same tool is called repeatedly with identical arguments
- Replace unconditional tool_choice="none" with conditional logic:
* Allow tool_choice="auto" when within limits and no loop detected
* Force tool_choice="none" only when limit exceeded or loop detected
Benefits:
- ✅ Prevents infinite loops (original PR oracle#50 goal)
- ✅ Enables multi-step tool orchestration (new capability)
- ✅ Fully backward compatible (default parameter, no breaking changes)
- ✅ Configurable per use case (users can adjust max limit)
- ✅ Domain-agnostic (works for any tool-calling application)
Example use cases now supported:
- Diagnostic workflows requiring 3-5 sequential tool calls
- Data analysis pipelines with multiple data fetching steps
- Complex reasoning tasks requiring iterative tool usage
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>1 parent a83c749 commit a011714
File tree
2 files changed
+65
-4
lines changed- libs/oci/langchain_oci
- chat_models
- llms
2 files changed
+65
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
747 | 747 | | |
748 | 748 | | |
749 | 749 | | |
750 | | - | |
751 | | - | |
752 | | - | |
| 750 | + | |
| 751 | + | |
753 | 752 | | |
754 | 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 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
755 | 807 | | |
756 | 808 | | |
757 | | - | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
758 | 815 | | |
759 | 816 | | |
760 | 817 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
119 | 123 | | |
120 | 124 | | |
121 | 125 | | |
| |||
0 commit comments