Skip to content

Commit dfb40d2

Browse files
committed
feat: conditionally handle reasoningOpaque in handleFinish based on tool block state
1 parent 3fa5519 commit dfb40d2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/routes/messages/stream-translation.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ function handleFinish(
5757
const { events, chunk } = context
5858
if (choice.finish_reason && choice.finish_reason.length > 0) {
5959
if (state.contentBlockOpen) {
60+
const toolBlockOpen = isToolBlockOpen(state)
6061
context.events.push({
6162
type: "content_block_stop",
6263
index: state.contentBlockIndex,
6364
})
6465
state.contentBlockOpen = false
6566
state.contentBlockIndex++
66-
handleReasoningOpaque(choice.delta, events, state)
67+
if (!toolBlockOpen) {
68+
handleReasoningOpaque(choice.delta, events, state)
69+
}
6770
}
6871

6972
events.push(

0 commit comments

Comments
 (0)