From a52d1bf475420cc47d0dcf47502c7c21d4e0ffcd Mon Sep 17 00:00:00 2001 From: Nikketryhard Date: Sat, 14 Feb 2026 23:19:28 -0600 Subject: [PATCH] fix: strip functionCall/functionResponse from history when no tools When LS tools are stripped from the request but the conversation history still contains functionCall/functionResponse parts referencing those tools, Google returns MALFORMED_FUNCTION_CALL and the LS retries in an infinite loop, causing the request to hang forever. Now after stripping LS tools and confirming no custom tools are injected, we also strip all functionCall/functionResponse parts from the history and remove any messages that become empty as a result. --- src/mitm/modify.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/mitm/modify.rs b/src/mitm/modify.rs index a056150..c73c301 100644 --- a/src/mitm/modify.rs +++ b/src/mitm/modify.rs @@ -156,6 +156,7 @@ pub fn modify_request(body: &[u8], tool_ctx: Option<&ToolContext>) -> Option) -> Option 0 { + changes.push(format!("strip {stripped_fc} functionCall/Response parts from history")); + } + } + } + // Inject toolConfig if provided if let Some(ref ctx) = tool_ctx { if let Some(ref config) = ctx.tool_config {