shell: stop sensor calls closing an open reasoning fence
A tool_call/tool_return arriving while a <think> block was open emitted its own self-closing fence, whose </think> closed the outer block early. Every reasoning token after that point rendered as prose, and the stray close left the trailing assistant text mis-segmented. Append inside the open fence instead; only open one when arriving in prose.
This commit is contained in:
parent
52f379f230
commit
a8f7f62471
1 changed files with 11 additions and 2 deletions
|
|
@ -356,13 +356,22 @@ Singleton {
|
|||
root.appendToStreaming(event.content);
|
||||
break;
|
||||
case "tool_call_message": {
|
||||
// A sensor firing mid-reasoning must not close the reasoning
|
||||
// fence. When a <think> block is already open we append inside it;
|
||||
// only a sensor arriving in prose opens a fence of its own.
|
||||
const call = event.tool_call;
|
||||
root.appendToStreaming(`\n\n<think>\nsensor: ${call.function.name}(${call.function.arguments})\n</think>\n`);
|
||||
const body = `sensor: ${call.function.name}(${call.function.arguments})`;
|
||||
root.appendToStreaming(root.inThinkBlock
|
||||
? `\n${body}\n`
|
||||
: `\n\n<think>\n${body}\n</think>\n`);
|
||||
break;
|
||||
}
|
||||
case "tool_return_message": {
|
||||
const ret = event.tool_return;
|
||||
root.appendToStreaming(`\n<think>\n[${ret.status}] ${ret.output}\n</think>\n`);
|
||||
const body = `[${ret.status}] ${ret.output}`;
|
||||
root.appendToStreaming(root.inThinkBlock
|
||||
? `\n${body}\n`
|
||||
: `\n<think>\n${body}\n</think>\n`);
|
||||
break;
|
||||
}
|
||||
case "interstitial":
|
||||
|
|
|
|||
Loading…
Reference in a new issue