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.
This commit is contained in:
parent
aafe86d81a
commit
0ce35a117c
1 changed files with 2 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue