Skip to content

Fix crash when OpenAI-compatible API returns tool_calls: null#34

Merged
chr15m merged 2 commits into
chr15m:mainfrom
spicyneuron:pr/empty-tools
May 7, 2026
Merged

Fix crash when OpenAI-compatible API returns tool_calls: null#34
chr15m merged 2 commits into
chr15m:mainfrom
spicyneuron:pr/empty-tools

Conversation

@spicyneuron

Copy link
Copy Markdown
Contributor

Some OpenAI-compatible APIs return "tool_calls": null in the message object when no tools are called, rather than omitting the key entirely.

.get("tool_calls", []) only substitutes the default for a missing key, so an explicit null passed through as None, causing a TypeError when iterating.

This fixes both extract_response and extract_tool_calls to use or [] so either case (missing key or explicit null) is handled safely.

@chr15m

chr15m commented May 7, 2026

Copy link
Copy Markdown
Owner

Thanks!

@chr15m chr15m merged commit 8b24d7c into chr15m:main May 7, 2026
9 checks passed
@spicyneuron spicyneuron deleted the pr/empty-tools branch May 7, 2026 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants