llm: make Tool.Run return ToolOut
This is preliminary work towards
allowing tools to add additional information.
No functional changes (at least, that's the intent).
diff --git a/llm/conversation/convo.go b/llm/conversation/convo.go
index b6472e1..a52d494 100644
--- a/llm/conversation/convo.go
+++ b/llm/conversation/convo.go
@@ -484,8 +484,8 @@
defer cancel()
// TODO: move this into newToolUseContext?
toolUseCtx = context.WithValue(toolUseCtx, toolCallInfoKey, ToolCallInfo{ToolUseID: part.ID, Convo: c})
- toolResult, err := tool.Run(toolUseCtx, part.ToolInput)
- if errors.Is(err, ErrDoNotRespond) {
+ toolOut := tool.Run(toolUseCtx, part.ToolInput)
+ if errors.Is(toolOut.Error, ErrDoNotRespond) {
return
}
if toolUseCtx.Err() != nil {
@@ -493,11 +493,11 @@
return
}
- if err != nil {
- sendErr(err)
+ if toolOut.Error != nil {
+ sendErr(toolOut.Error)
return
}
- sendRes(toolResult)
+ sendRes(toolOut.LLMContent)
}()
}
wg.Wait()