mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 05:39:05 +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({
|
chunks.push({
|
||||||
type: 'tool-result',
|
type: 'tool-result',
|
||||||
toolCallId: block.tool_use_id,
|
toolCallId: block.tool_use_id,
|
||||||
toolName: contentBlockState[blockKey].toolName,
|
toolName: contentBlockState[block.tool_use_id].toolName,
|
||||||
input: '',
|
input: '',
|
||||||
output: block.content
|
output: block.content
|
||||||
})
|
})
|
||||||
@ -144,7 +144,7 @@ function handleStreamEvent(message: Extract<SDKMessage, { type: 'stream_event' }
|
|||||||
const chunks: AgentStreamPart[] = []
|
const chunks: AgentStreamPart[] = []
|
||||||
const event = message.event
|
const event = message.event
|
||||||
const blockKey = `${message.uuid ?? message.session_id ?? 'session'}:${event.type}`
|
const blockKey = `${message.uuid ?? message.session_id ?? 'session'}:${event.type}`
|
||||||
|
logger.debug('Handling stream event:', { event })
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case 'message_start':
|
case 'message_start':
|
||||||
// No specific UI chunk needed for message start in this protocol
|
// No specific UI chunk needed for message start in this protocol
|
||||||
@ -169,7 +169,7 @@ function handleStreamEvent(message: Extract<SDKMessage, { type: 'stream_event' }
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'tool_use': {
|
case 'tool_use': {
|
||||||
contentBlockState.set(blockKey, {
|
contentBlockState.set(event.content_block.id, {
|
||||||
type: 'tool-call',
|
type: 'tool-call',
|
||||||
toolCallId: event.content_block.id,
|
toolCallId: event.content_block.id,
|
||||||
toolName: event.content_block.name,
|
toolName: event.content_block.name,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user