Skip to content

fix: crash on None entry in tool_calls list during Anthropic conversion#2209

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
0xbyt4:fix/null-tool-call-crash
Mar 20, 2026
Merged

fix: crash on None entry in tool_calls list during Anthropic conversion#2209
teknium1 merged 1 commit intoNousResearch:mainfrom
0xbyt4:fix/null-tool-call-crash

Conversation

@0xbyt4
Copy link
Copy Markdown
Contributor

@0xbyt4 0xbyt4 commented Mar 20, 2026

Summary

convert_messages_to_anthropic crashes with AttributeError: 'NoneType' object has no attribute 'get' when a tool_calls list contains a None entry.

This can happen from:

  • Malformed API response
  • Compression artifact
  • Corrupt session replay from disk

Fix

Skip None and non-dict entries in the tool_calls iteration (line 866):

for tc in m.get("tool_calls", []):
    if not tc or not isinstance(tc, dict):
        continue

Test plan

  • Crash reproduced before fix
  • Fix verified: None skipped, valid tool_calls preserved
  • 76 existing anthropic adapter tests pass
  • No behavioral change for well-formed tool_calls
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.
@teknium1 teknium1 merged commit 0ce35a1 into NousResearch:main Mar 20, 2026
1 check passed
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
…on (NousResearch#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants