fix: restore chunk flow by refining tool detection
All checks were successful
BotServer CI/CD / build (push) Successful in 3m39s
All checks were successful
BotServer CI/CD / build (push) Successful in 3m39s
This commit is contained in:
parent
fc0144c67c
commit
c8514eabe7
1 changed files with 5 additions and 4 deletions
|
|
@ -912,15 +912,16 @@ impl BotOrchestrator {
|
||||||
continue; // Important: do not append to full_response or tool_buffer
|
continue; // Important: do not append to full_response or tool_buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if this chunk contains JSON (either starts with {/[ or contains {/[)
|
// Check if this chunk contains a tool call start
|
||||||
let chunk_contains_json = chunk.trim().starts_with('{') || chunk.trim().starts_with('[') ||
|
// We only accumulate if it strongly resembles a tool call to avoid swallowing regular JSON/text
|
||||||
chunk.contains('{') || chunk.contains('[');
|
let looks_like_tool_start = (chunk.trim().starts_with('{') || chunk.trim().starts_with('[')) &&
|
||||||
|
(chunk.contains("\"id\":\"call_") || chunk.contains("\"type\":\"tool_call\"") || chunk.contains("\"function\":"));
|
||||||
|
|
||||||
let chunk_in_tool_buffer = if accumulating_tool_call {
|
let chunk_in_tool_buffer = if accumulating_tool_call {
|
||||||
// Already accumulating - add entire chunk to buffer
|
// Already accumulating - add entire chunk to buffer
|
||||||
tool_call_buffer.push_str(&chunk);
|
tool_call_buffer.push_str(&chunk);
|
||||||
true
|
true
|
||||||
} else if chunk_contains_json {
|
} else if looks_like_tool_start {
|
||||||
// Check if { appears in the middle of the chunk (mixed text + JSON)
|
// Check if { appears in the middle of the chunk (mixed text + JSON)
|
||||||
let json_start = chunk.find('{').or_else(|| chunk.find('['));
|
let json_start = chunk.find('{').or_else(|| chunk.find('['));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue