From 19ff784caeb556a9701e6ab1c0d9087c9c40c51a Mon Sep 17 00:00:00 2001 From: Nikketryhard Date: Sat, 14 Feb 2026 23:59:13 -0600 Subject: [PATCH] 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. --- src/mitm/modify.rs | 7 ++++++- src/mitm/proxy.rs | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mitm/modify.rs b/src/mitm/modify.rs index bebf2cc..94e25bc 100644 --- a/src/mitm/modify.rs +++ b/src/mitm/modify.rs @@ -206,8 +206,13 @@ pub fn modify_request(body: &[u8], tool_ctx: Option<&ToolContext>) -> Option= 400 { + let body_preview = String::from_utf8_lossy(&header_buf[hdr_end..]); + warn!(domain, status = resp.code.unwrap_or(0), body = %body_preview, "MITM: upstream error response"); + } + // Save body for usage parsing response_body_buf.extend_from_slice(&header_buf[hdr_end..]);