Skip to content

fix(crew): treat empty tool-call arguments as no arguments - #157

Open
Shraman123 wants to merge 1 commit into
smallest-inc:mainfrom
Shraman123:crew-tool-empty-arguments
Open

Shraman123 wants to merge 1 commit into
smallest-inc:mainfrom
Shraman123:crew-tool-empty-arguments

Conversation

@Shraman123

Copy link
Copy Markdown

Problem

OpenAIClient accumulates streamed tool-call argument deltas starting from "" and skips empty deltas, so a call to a zero-parameter tool (end_call, transfer, …) from a provider that streams no argument text arrives with arguments == "". ToolRegistry._execute_single then does json.loads(""), which raises: the tool never runs and the LLM gets Expecting value: line 1 column 1 (char 0) back as a tool error.

Repro on main:

import asyncio
from smallestai.atoms.crew.tools import function_tool
from smallestai.atoms.crew.tools.registry import ToolRegistry
from smallestai.atoms.crew.clients.types import ToolCall

@function_tool
def end_call():
    """End the call."""
    return "ok"

r = ToolRegistry(); r.register(end_call)
[res] = asyncio.run(r.execute([ToolCall(id="1", name="end_call", arguments="")]))
print(res.is_error, res.content)
# True  Expecting value: line 1 column 1 (char 0)

Fix

Empty / whitespace-only arguments are parsed as {}. Malformed JSON is still reported as an error, as before. Change is in src/smallestai/atoms/crew/tools/registry.py (.fernignored).

Tests

New tests/custom/test_tool_registry_empty_arguments.py:

  • "", " ", "{}" → the tool runs, is_error=False (the first two fail on main)
  • malformed JSON → still is_error=True with the call's id

pytest tests/custom: 280 passed; the only 2 failures (test_region_aware_auth) fail identically on main locally and are unrelated. ruff check clean on the changed files.

🤖 Generated with Claude Code

OpenAIClient accumulates streamed argument deltas from "" and skips empty
ones, so a call to a zero-parameter tool (end_call, transfer, ...) from a
provider that streams no argument text arrives with arguments == "".
json.loads("") raised, the tool never ran, and the LLM got "Expecting
value: line 1 column 1 (char 0)" back as a tool error.

Parse empty/blank arguments as {}. Malformed JSON is still an error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@crim-app

crim-app Bot commented Nov 15, 2026

Copy link
Copy Markdown

crim doesn't review pull requests automatically here.

Comment crim review on this pull request whenever you want a review.

This branch has not been deployed

No deployments
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.

1 participant