Skip to content

Python: [Bug]: ClaudeAgent sends tools declared with a JSON schema to Claude without their parameters #9301

Closed

Description

Observed Behavior

When a FunctionTool is declared with a JSON schema dict, ClaudeAgent exposes it to Claude with an empty input schema: {"type": "object", "properties": {}, "required": []}. Claude sees a tool that takes no arguments, so it calls the tool without the arguments the function needs.

This affects every tool whose parameters come from a dict schema, for example:

  • @tool(schema={...}) and FunctionTool(input_model={...})
  • Agent.as_tool() (sub-agents used as tools)
  • the vector store tools (create_vector_search_tool and the other create_*_tool helpers)

Tools built from a Pydantic model or inferred from the function signature are not affected.

Expected Behavior

Claude receives the parameters the tool declares, the same as for a tool built from a Pydantic model.

Steps to Reproduce

  1. Declare a tool with a JSON schema dict.
  2. Pass it to ClaudeAgent.
  3. Look at the input schema of the SDK tool that ClaudeAgent builds for it.

Minimal Reproduction

from agent_framework import tool
from agent_framework_claude import ClaudeAgent


@tool(schema={"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]})
def get_weather(city: str) -> str:
    """Get the weather for a city."""
    return f"Sunny in {city}"


agent = ClaudeAgent(tools=[get_weather])
sdk_tool = agent._function_tool_to_sdk_mcp_tool(get_weather)
print(get_weather.parameters())  # {'type': 'object', 'properties': {'city': {'type': 'string'}}, 'required': ['city']}
print(sdk_tool.input_schema)     # {'type': 'object', 'properties': {}, 'required': []}

The cause is in agent_framework_claude/_agent.py (_function_tool_to_sdk_mcp_tool): the schema is read from func_tool.input_model.model_json_schema() and falls back to {} when input_model is None. A FunctionTool declared with a dict schema keeps input_model = None and serves its schema through FunctionTool.parameters(). The GitHub Copilot agent already uses parameters() for this.

Error Messages and Stack Traces

No error from the framework. Claude calls the tool with no arguments, and the call fails or returns a wrong result depending on the tool.

Package Versions

agent-framework-claude: 1.0.0b261002 (main at a75e803), agent-framework-core: 1.21.0, claude-agent-sdk: 0.2.163

Python Version

Python 3.12

Additional Context

I'd like to fix this. The change is one line in _function_tool_to_sdk_mcp_tool (read the schema from func_tool.parameters()) plus a regression test.

AI assistance: I used an AI coding assistant for the analysis and to draft this report. I reproduced and verified the behavior myself.

Metadata

Metadata

Labels

pythonUsage: [Issues, PRs], Target: Python

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions