Commit b53a06a
authored
… tool call failures
When a tool defined via reflection throws an exception, the AIAgentError
is incorrectly populated, becase the exception thrown from the
reflective call is wrapped in an InvocationTargetException with null
message:
```
Tool with name 'exceptionTool' failed to execute with arguments: VarArgs(args={})
java.lang.reflect.InvocationTargetException: null
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97)
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Static.call(CallerImpl.kt:106)
at kotlin.reflect.jvm.internal.KCallableImpl.callDefaultMethod$kotlin_reflection(KCallableImpl.kt:159)
at kotlin.reflect.jvm.internal.KCallableImpl.callBy(KCallableImpl.kt:112)
at kotlin.jvm.internal.CallableReference.callBy(CallableReference.java:166)
at kotlin.reflect.full.KCallables.callSuspendBy(KCallables.kt:71)
at ai.koog.agents.core.tools.reflect.ToolFromCallable.execute(ToolFromCallable.kt:110)
...
Caused by: java.lang.RuntimeException: This is a test exception
```
The AIAgentError is then populated with the default message "Unknown
error":
`AIAgentError(message=Unknown error,
stackTrace=java.lang.reflect.InvocationTargetException ...`
This results in the agent receiving the tool call result without the
exception message.
```
{
content: "Tool with name 'exceptionTool' failed to execute due to the error: null!"
role: "tool"
}
```
closes KG-704
Co-authored-by: Michal Borowiecki <6325352+mihbor@users.noreply.github.com>
1 parent a8483e0 commit b53a06a
2 files changed
Lines changed: 19 additions & 1 deletion
File tree
- agents/agents-tools/src
- jvmCommonMain/kotlin/ai/koog/agents/core/tools/reflect
- jvmTest/kotlin/ai/koog/agents/core/tools/reflect
agents/agents-tools/src/jvmCommonMain/kotlin/ai/koog/agents/core/tools/reflect/ToolFromCallable.kt
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
94 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
95 | 100 | | |
96 | 101 | | |
97 | 102 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
33 | 40 | | |
34 | 41 | | |
35 | 42 | | |
| |||
517 | 524 | | |
518 | 525 | | |
519 | 526 | | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
520 | 533 | | |
521 | 534 | | |
522 | 535 | | |
| |||
0 commit comments