Skip to content

Using commands as agent-framework tools

app.tools() returns each command as a plain Python function with a real signature, type hints and docstring. Agent frameworks read exactly these to build tools, so no adapter is needed:

from todo_axi.cli import app

# todo_axi_home, todo_axi_list, todo_axi_view, todo_axi_add, todo_axi_close
tools = app.tools()

# PydanticAI
agent = Agent("anthropic:claude-sonnet-5-5", tools=tools)

# LangChain
lc_tools = [StructuredTool.from_function(t) for t in tools]

# OpenAI Agents SDK
oa_tools = [function_tool(t) for t in tools]

A tool takes the same arguments as the CLI command and returns the same text. For CSV, the count and suggestions follow the rows:

>>> todo_axi_list(assignee="alice", fields=["id", "title", "due"])
id,title,due
41,Fix login redirect,2026-11-24
45,Upgrade pydantic,
count: 2 of 2 total
help[1]: todo-axi view <id>

>>> todo_axi_view(id=99)
error: todo 99 not found
help[1]: todo-axi list
  • Pydantic-model parameters are flattened into their fields, as on the CLI. List commands also take fields, and commands with truncated text take full.
  • Errors are returned as text the agent can act on. Pass app.tools(errors="raise") to get fastaxi.tools.AxiToolError instead.
  • Async commands become async tools.
  • Choose what's exposed with include=["list", "view"], exclude=[...], prefix="todo" and home=False. The built-in setup commands are never included.

For raw tool-calling APIs, tool_spec gives the name, description and JSON schema:

>>> from fastaxi.tools import tool_spec
>>> spec = tool_spec(todo_axi_view)
>>> spec.name
'todo_axi_view'
>>> spec.parameters
{'properties': {'id': {'description': 'Todo id', 'title': 'Id', 'type': 'integer'},
                'full': {'default': False, 'description': 'Return long text without truncation',
                         'title': 'Full', 'type': 'boolean'}},
 'required': ['id'], 'title': 'todo_axi_view_args', 'type': 'object'}