* Handle the end of a tool invocation
(output: string | object, runId: string, parentRunId?: string)
| 2004 | * Handle the end of a tool invocation |
| 2005 | */ |
| 2006 | async handleToolEnd(output: string | object, runId: string, parentRunId?: string): Promise<void> { |
| 2007 | if (!this.sseStreamer) return |
| 2008 | |
| 2009 | const toolOutput = typeof output === 'string' ? output : JSON.stringify(output, null, 2) |
| 2010 | |
| 2011 | // Stream the tool output details using the agent_trace event type for consistency |
| 2012 | this.sseStreamer.streamCustomEvent(this.chatId, 'agent_trace', { |
| 2013 | step: 'tool_end', |
| 2014 | output: toolOutput, |
| 2015 | runId, |
| 2016 | parentRunId: parentRunId || null |
| 2017 | }) |
| 2018 | } |
| 2019 | |
| 2020 | /** |
| 2021 | * Handle tool errors |