Emit OnToolEnd hooks for interrupted and failed tools
executeSingleTool had three exit paths but only the success path emitted all end signals. The interrupted path (nested agent approval) skipped OnToolEnd and StreamEventToolEnd entirely, leaving hook consumers with an unpaired OnToolStart. The error path also missed StreamEventToolEnd and AgentHooks.OnToolEnd. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -134,10 +134,11 @@ func (g *outputBlocker) Check(_ context.Context, message llm.Message) (*agent.Gu
|
||||
|
||||
type recordingHook struct {
|
||||
agent.NoOpHooks
|
||||
runStarted bool
|
||||
runEnded bool
|
||||
toolNames []string
|
||||
handoffs []string
|
||||
runStarted bool
|
||||
runEnded bool
|
||||
toolStartNames []string
|
||||
toolNames []string
|
||||
handoffs []string
|
||||
}
|
||||
|
||||
func (h *recordingHook) OnRunStart(_ context.Context, _ *agent.Agent, _ []llm.Message) {
|
||||
@@ -148,6 +149,10 @@ func (h *recordingHook) OnRunEnd(_ context.Context, _ *agent.Agent, _ *agent.Res
|
||||
h.runEnded = true
|
||||
}
|
||||
|
||||
func (h *recordingHook) OnToolStart(_ context.Context, _ *agent.Agent, tool agent.Tool, _ string) {
|
||||
h.toolStartNames = append(h.toolStartNames, tool.Name())
|
||||
}
|
||||
|
||||
func (h *recordingHook) OnToolEnd(_ context.Context, _ *agent.Agent, tool agent.Tool, _ agent.ToolResult, _ error) {
|
||||
h.toolNames = append(h.toolNames, tool.Name())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user