Execute runs a tool call and returns the (possibly truncated) result ready to be appended to the conversation as a `tool` message.
(parent context.Context, call chmctx.ToolCall)
| 123 | // Execute runs a tool call and returns the (possibly truncated) result ready |
| 124 | // to be appended to the conversation as a `tool` message. |
| 125 | func Execute(parent context.Context, call chmctx.ToolCall) chmctx.Message { |
| 126 | raw := runRaw(parent, call) |
| 127 | return chmctx.Message{ |
| 128 | Role: chmctx.RoleTool, |
| 129 | Content: chmctx.Truncate(raw), |
| 130 | ToolCallID: call.ID, |
| 131 | ToolName: call.Name, |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | func runRaw(parent context.Context, call chmctx.ToolCall) string { |
| 136 | // A truncated/oversized tool call leaves llm.resolve()'s _parse_error |