MCPcopy Create free account
hub / github.com/xerrors/Yuxi / toolFinishedMessage

Function toolFinishedMessage

web/src/composables/useAgentStreamHandler.js:65–78  ·  view source on GitHub ↗
(chunk)

Source from the content-addressed store, hash-verified

63// 工具结果不走 messages 流,而是以 method=tools 的 stream_event 事件返回(tool-started/tool-finished)。
64// 取出 tool-finished 的 output(一条 ToolMessage 字典),交给 msgChunks 与 AI 消息按 tool_call_id 关联。
65const toolFinishedMessage = (chunk) => {
66 const streamEvent = chunk?.event
67 if (!streamEvent || streamEvent.method !== 'tools') return null
68
69 const data = streamEvent.data
70 if (!data || data.event !== 'tool-finished') return null
71
72 const output = data.output
73 if (!output || typeof output !== 'object') return null
74
75 const id = output.id || output.tool_call_id || data.tool_call_id
76 if (!id) return null
77 return { ...output, type: 'tool', id }
78}
79
80export function useAgentStreamHandler({
81 getThreadState,

Callers 1

handleStreamChunkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected