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:
Nikketryhard
2026-02-15 00:37:39 -06:00
parent 502318acec
commit 5d4125fa0d
2 changed files with 31 additions and 35 deletions

View File

@@ -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;
}