fix: always strip old functionCall/functionResponse from LS history
The function call stripping was only happening when no custom tools were present. But even with custom tools injected, the LS history contains functionCall/functionResponse parts for LS-internal tools that we stripped, causing MALFORMED_FUNCTION_CALL. Now always strip regardless of custom tools presence.
This commit is contained in:
@@ -206,8 +206,13 @@ pub fn modify_request(body: &[u8], tool_ctx: Option<&ToolContext>) -> Option<Vec
|
||||
changes.push("remove toolConfig (no tools)".to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Also strip functionCall/functionResponse from conversation history
|
||||
// ── 3b. ALWAYS strip old functionCall/functionResponse from history ───
|
||||
// Even when custom tools are injected, the LS history contains function
|
||||
// call parts for LS-internal tools we stripped. Google rejects these as
|
||||
// MALFORMED_FUNCTION_CALL because the referenced tools don't exist.
|
||||
if STRIP_ALL_TOOLS {
|
||||
if let Some(contents) = json
|
||||
.pointer_mut("/request/contents")
|
||||
.and_then(|v| v.as_array_mut())
|
||||
|
||||
Reference in New Issue
Block a user