diff options
Diffstat (limited to '')
| -rw-r--r-- | src/provider.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/provider.rs b/src/provider.rs index 1b9e220..0973e8c 100644 --- a/src/provider.rs +++ b/src/provider.rs | |||
| @@ -358,7 +358,17 @@ pub fn chat_with( | |||
| 358 | } | 358 | } |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | outcome.tool_calls = calls.into_values().collect(); | 361 | let before = calls.len(); |
| 362 | outcome.tool_calls = calls | ||
| 363 | .into_values() | ||
| 364 | // Some backends emit an empty placeholder alongside a real call; asking | ||
| 365 | // a human to approve a blank command is worse than dropping it. | ||
| 366 | .filter(|call| !(call.name.is_empty() && call.arguments.trim().is_empty())) | ||
| 367 | .collect(); | ||
| 368 | let dropped_calls = before - outcome.tool_calls.len(); | ||
| 369 | if dropped_calls > 0 { | ||
| 370 | eprintln!("agent686: ignored {dropped_calls} empty tool call(s)"); | ||
| 371 | } | ||
| 362 | if outcome.usage.as_ref().is_some_and(|u| u.is_null()) { | 372 | if outcome.usage.as_ref().is_some_and(|u| u.is_null()) { |
| 363 | outcome.usage = None; | 373 | outcome.usage = None; |
| 364 | } | 374 | } |
| @@ -393,6 +403,9 @@ fn handle_event( | |||
| 393 | if data.is_empty() { | 403 | if data.is_empty() { |
| 394 | return false; | 404 | return false; |
| 395 | } | 405 | } |
| 406 | if std::env::var_os("AGENT686_DEBUG_STREAM").is_some() { | ||
| 407 | eprintln!("sse: {}", truncate(data, 400)); | ||
| 408 | } | ||
| 396 | if data.trim() == "[DONE]" { | 409 | if data.trim() == "[DONE]" { |
| 397 | *completed = true; | 410 | *completed = true; |
| 398 | return true; | 411 | return true; |
