Commit 83af651
committed
Enhance tool calling to support multi-step orchestration
This commit improves the Meta Llama tool calling infinite loop fix by
replacing the overly restrictive single-tool limitation with intelligent
multi-step support that allows up to 8 sequential tool calls.
Changes:
- Add max_sequential_tool_calls parameter (default: 8) to OCIGenAIBase
- Implement loop detection algorithm that identifies when the same tool
is called repeatedly with identical arguments
- Replace unconditional tool_choice="none" with conditional logic that
only forces stop when limit exceeded or loop detected
- Otherwise allow default model behavior for continued tool calling
Benefits:
- Prevents infinite loops (original goal maintained)
- Enables multi-step tool orchestration (new capability)
- Fully backward compatible via default parameter
- Configurable per use case
- Domain-agnostic implementation
Tested with integration tests showing successful multi-step workflows
for diagnostic and remediation scenarios.1 parent a83c749 commit 83af651
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