From 0ce35a117c2e142ab082cacec4287856b1d022d6 Mon Sep 17 00:00:00 2001 From: 0xbyt4 <35742124+0xbyt4@users.noreply.github.com> Date: Fri, 20 Mar 2026 22:01:42 +0300 Subject: [PATCH] fix: crash on None entry in tool_calls list during Anthropic conversion (#2209) If a tool_calls list contains a None entry (from malformed API response, compression artifact, or corrupt session replay), convert_messages_to_anthropic crashes with AttributeError: 'NoneType' object has no attribute 'get'. Skip None and non-dict entries in the tool_calls iteration. Found via chaos/fuzz testing with mixed valid/invalid tool_call entries. --- agent/anthropic_adapter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/agent/anthropic_adapter.py b/agent/anthropic_adapter.py index 1bf0e951..5a8d8365 100644 --- a/agent/anthropic_adapter.py +++ b/agent/anthropic_adapter.py @@ -864,6 +864,8 @@ def convert_messages_to_anthropic( else: blocks.append({"type": "text", "text": str(content)}) for tc in m.get("tool_calls", []): + if not tc or not isinstance(tc, dict): + continue fn = tc.get("function", {}) args = fn.get("arguments", "{}") try: