Add stream event logging to worker engine for debugging
Logs every SSE event and final message content block types to stdout to diagnose what the user sees as "full tool calls" in Telegram. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -178,7 +178,7 @@ Current working directory: ${this.config.defaultCwd}`
|
||||
fullText += text
|
||||
})
|
||||
|
||||
// Process events from the stream
|
||||
// Process events from the stream — log every event for debugging
|
||||
for await (const event of stream) {
|
||||
if (abortController.signal.aborted) {
|
||||
stream.abort()
|
||||
@@ -186,6 +186,8 @@ Current working directory: ${this.config.defaultCwd}`
|
||||
return
|
||||
}
|
||||
|
||||
console.log(`[stream-event] ${JSON.stringify(event)}`)
|
||||
|
||||
if (event.type === 'content_block_delta') {
|
||||
const delta = event.delta as { type?: string; text?: string }
|
||||
if (delta?.type === 'text_delta' && delta.text) {
|
||||
@@ -199,6 +201,7 @@ Current working directory: ${this.config.defaultCwd}`
|
||||
|
||||
// Get final message for usage
|
||||
const finalMessage = await stream.finalMessage()
|
||||
console.log(`[final-message] stop_reason=${finalMessage.stop_reason} content_blocks=${JSON.stringify(finalMessage.content.map(b => ({ type: b.type, ...(b.type === 'tool_use' ? { name: (b as any).name } : {}) })))}`)
|
||||
|
||||
// Add assistant response to history
|
||||
const assistantText =
|
||||
|
||||
Reference in New Issue
Block a user