Commit a4d5bfe
committed
Return error response for unknown tool calls instead of silently skipping
Two improvements:
1. Bug fix - unknown tool calls get an error response instead of being silently dropped. On main, when the model calls a tool that doesn't
exist (the else branch), the call is skipped with no tool response message added to the session. This leaves a tool_call without a
matching tool_response, which violates the LLM API contract and can cause errors or confused model behavior on the next turn. This
commonly happens after a handoff: agent A sees tool calls from agent B in the conversation history and tries to use them. Now it gets a
clear error telling it the tool isn't available.
2. Simpler structure - one availability check instead of two separate rejection paths. On main, the availability logic has three branches
with two different rejection paths.
The new code separates this into two sequential steps: check agentToolMap once (reject if missing), then pick the handler. This removes
the nested if, deduplicates the rejection logic, and makes the flow read top-down: is it available ‚Üí how do we run it ‚Üí run it.
Assisted-By: cagent1 parent a1ae6ce commit a4d5bfe
2 files changed
+24
-33
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1437 | 1437 | | |
1438 | 1438 | | |
1439 | 1439 | | |
1440 | | - | |
1441 | | - | |
1442 | | - | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
1443 | 1453 | | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
1444 | 1457 | | |
1445 | | - | |
1446 | | - | |
1447 | | - | |
1448 | | - | |
1449 | | - | |
1450 | | - | |
1451 | | - | |
1452 | | - | |
1453 | | - | |
1454 | | - | |
1455 | | - | |
1456 | | - | |
1457 | | - | |
| 1458 | + | |
1458 | 1459 | | |
1459 | | - | |
1460 | | - | |
1461 | | - | |
1462 | | - | |
| 1460 | + | |
1463 | 1461 | | |
1464 | 1462 | | |
1465 | 1463 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
862 | 862 | | |
863 | 863 | | |
864 | 864 | | |
865 | | - | |
866 | | - | |
| 865 | + | |
867 | 866 | | |
868 | 867 | | |
869 | 868 | | |
870 | 869 | | |
871 | 870 | | |
872 | | - | |
873 | | - | |
874 | 871 | | |
875 | 872 | | |
876 | 873 | | |
877 | 874 | | |
878 | | - | |
879 | 875 | | |
880 | 876 | | |
881 | 877 | | |
882 | 878 | | |
883 | 879 | | |
884 | 880 | | |
885 | 881 | | |
886 | | - | |
887 | | - | |
888 | 882 | | |
889 | | - | |
890 | | - | |
891 | 883 | | |
892 | 884 | | |
893 | 885 | | |
894 | 886 | | |
895 | | - | |
| 887 | + | |
| 888 | + | |
896 | 889 | | |
897 | 890 | | |
898 | | - | |
899 | | - | |
| 891 | + | |
900 | 892 | | |
901 | 893 | | |
902 | | - | |
| 894 | + | |
| 895 | + | |
903 | 896 | | |
904 | 897 | | |
905 | 898 | | |
| |||
0 commit comments