mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 18:50:56 +08:00
Fix toolName reference and add stream event logging
- Correct toolName lookup to use tool_use_id instead of blockKey in tool-result chunks - Add debug logging for stream event handling - Update contentBlockState key to use event.content_block.id for tool_use events
This commit is contained in:
parent
8fbb93b0bf
commit
17a27f0d55
@ -118,7 +118,7 @@ function handleUserOrAssistantMessage(message: Extract<SDKMessage, { type: 'assi
|
||||
chunks.push({
|
||||
type: 'tool-result',
|
||||
toolCallId: block.tool_use_id,
|
||||
toolName: contentBlockState[blockKey].toolName,
|
||||
toolName: contentBlockState[block.tool_use_id].toolName,
|
||||
input: '',
|
||||
output: block.content
|
||||
})
|
||||
@ -144,7 +144,7 @@ function handleStreamEvent(message: Extract<SDKMessage, { type: 'stream_event' }
|
||||
const chunks: AgentStreamPart[] = []
|
||||
const event = message.event
|
||||
const blockKey = `${message.uuid ?? message.session_id ?? 'session'}:${event.type}`
|
||||
|
||||
logger.debug('Handling stream event:', { event })
|
||||
switch (event.type) {
|
||||
case 'message_start':
|
||||
// No specific UI chunk needed for message start in this protocol
|
||||
@ -169,7 +169,7 @@ function handleStreamEvent(message: Extract<SDKMessage, { type: 'stream_event' }
|
||||
break
|
||||
}
|
||||
case 'tool_use': {
|
||||
contentBlockState.set(blockKey, {
|
||||
contentBlockState.set(event.content_block.id, {
|
||||
type: 'tool-call',
|
||||
toolCallId: event.content_block.id,
|
||||
toolName: event.content_block.name,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user