Commit 9700109
Distinguish exception-originated failures from deliberate ones
The previous commit broke test_handles_tool_calling_errors because
define_tool's exception handler wraps exceptions as ToolResult(failure),
which was then sent as a structured result instead of a top-level error.
Fix: introduce TOOL_EXCEPTION_TEXT constant shared between define_tool's
exception handler and _execute_tool_and_respond. When the failure's
textResultForLlm matches the known exception wrapper message, send via
the top-level error param (CLI formats as 'Failed to execute...');
otherwise send the full structured result to preserve metadata.
This preserves backward compatibility for thrown exceptions while
allowing user-returned ToolResult(failure) to carry toolTelemetry.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 5a8206c commit 9700109
2 files changed
Lines changed: 32 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
944 | 944 | | |
945 | 945 | | |
946 | 946 | | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
953 | 959 | | |
954 | | - | |
955 | | - | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
956 | 973 | | |
957 | | - | |
958 | 974 | | |
959 | 975 | | |
960 | 976 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
195 | 200 | | |
196 | 201 | | |
197 | 202 | | |
198 | | - | |
199 | | - | |
| 203 | + | |
200 | 204 | | |
201 | 205 | | |
202 | 206 | | |
| |||
0 commit comments