Skip to content

fix: handle None args in build_tool_preview#453

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
0xbyt4:fix/display-none-args
Mar 10, 2026
Merged

fix: handle None args in build_tool_preview#453
teknium1 merged 1 commit intoNousResearch:mainfrom
0xbyt4:fix/display-none-args

Conversation

@0xbyt4
Copy link
Contributor

@0xbyt4 0xbyt4 commented Mar 5, 2026

Summary

  • build_tool_preview() crashes with TypeError: argument of type 'NoneType' is not iterable when a model returns null/empty tool call arguments
  • json.loads("null") produces None, which is passed to build_tool_preview where fallback_key in args fails
  • Added early return when args is falsy

When an LLM returns null/empty tool call arguments, json.loads()
produces None. build_tool_preview then crashes with
"argument of type 'NoneType' is not iterable" on the `in` check.
Return None early when args is falsy.
teknium1 added a commit that referenced this pull request Mar 10, 2026
…tool_preview

Complements PR #453 by 0xbyt4. Adds isinstance(dict) guard in
run_agent.py to catch cases where json.loads returns non-dict
(e.g. null, list, string) before they reach downstream code.

Also adds 15 tests for build_tool_preview covering None args,
empty dicts, known/unknown tools, fallback keys, truncation,
and all special-cased tools (process, todo, memory, session_search).
@teknium1 teknium1 merged commit 28ae5db into NousResearch:main Mar 10, 2026
1 check passed
@teknium1
Copy link
Contributor

Merged! Thanks for the fix @0xbyt4 🎉

Added a complementary guard upstream in run_agent.py (commit 3e352f8) to ensure function_args is always a dict even when json.loads returns non-dict types (null, list, etc.) — this catches the issue before it reaches build_tool_preview() or any other downstream code.

Also added 15 tests for build_tool_preview() covering None args, empty dicts, all special-cased tools, fallback keys, and truncation.

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