Merge pull request #386 from kevin9327/fix/empty-tool-arguments

fix: handle tool calls with empty arguments
This commit is contained in:
leokun authored and GitHub committed 2026-08-31 13:57:45 +08:00
commit 45e694fd63
3 files changed
+78 -2

No files matched your search

+8 -1
View File
@@ -343,7 +343,14 @@ impl ConversationOutput {
let call = calls.get_mut(&index).ok_or_else(|| {
Error::Protocol(format!("unknown completed tool index: {index}"))
})?;
call.arguments = serde_json::from_str(&call.arguments_text)?;
// A tool call with no arguments streams no argument text.
// Treat empty text as an empty object, matching the model
// cycle, instead of failing the run on `from_str("")`.
call.arguments = if call.arguments_text.trim().is_empty() {
serde_json::json!({})
} else {
serde_json::from_str(&call.arguments_text)?
};
}
RunEvent::Usage(usage) => {
if !self.context.compacting {