fix: suppress dummy text from tool call responses
Check for MITM-captured function calls BEFORE emitting text in the streaming handler. This prevents the dummy 'Tool call completed' placeholder (sent to the LS) from leaking to OpenCode, which was confusing it into infinite loops. Also removes duplicate function call storage at end of response loop since they're now stored immediately when detected.
This commit is contained in:
@@ -850,14 +850,8 @@ async fn handle_http_over_tls(
|
||||
// Capture usage data
|
||||
if is_streaming_response {
|
||||
if streaming_acc.is_complete || streaming_acc.output_tokens > 0 {
|
||||
// Save any captured function calls before consuming the accumulator
|
||||
for fc in &streaming_acc.function_calls {
|
||||
store.record_function_call(cascade_hint.as_deref(), fc.clone()).await;
|
||||
}
|
||||
// Also save for history rewriting on tool result turns
|
||||
if !streaming_acc.function_calls.is_empty() {
|
||||
store.set_last_function_calls(streaming_acc.function_calls.clone()).await;
|
||||
}
|
||||
// Function calls are stored immediately when detected (above),
|
||||
// so no need to store them again here.
|
||||
let usage = streaming_acc.into_usage();
|
||||
store.record_usage(cascade_hint.as_deref(), usage).await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user