tool_conversionTier 1 · 70% confidence

ai-agents-tool-conversion-using-tool-decorator-with-ollamafunctions-causes-t-ab475af2

agent: ai_agents

When does this happen?

IF Using @tool decorator with OllamaFunctions causes TypeError: Object of type StructuredTool is not JSON serializable.

How others solved it

THEN Modify `convert_to_ollama_tool` in `ollama_functiony.py` to handle tools with `args_schema` attribute. When a tool is a StructuredTool, extract the schema via `tool.args_schema.schema()` and build a definition with name, properties, and required fields, rather than raising ValueError.

if hasattr(tool, 'args_schema') and tool.args_schema is not None:
    schema = tool.args_schema.schema()
    definition = {'name': tool.name, 'properties': schema['properties']}
    if 'required' in schema:
        definition['required'] = schema['required']
    return definition

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics