Medox add-agent-tool
Add a new LangChain tool to the Medox ReAct agent. Use when creating a new tool file, registering it in the graph, and writing its test.
install
source · Clone the upstream repo
git clone https://github.com/spideystreet/medox
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/spideystreet/medox "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.claude/skills/add-agent-tool" ~/.claude/skills/spideystreet-medox-add-agent-tool && rm -rf "$T"
manifest:
.claude/skills/add-agent-tool/SKILL.mdsource content
Skill: Add a New Agent Tool
Steps
-
Create the tool file at
:src/medox/agent/tools/tool_<name>.py"""One-line description of the data source and lookup strategy.""" from langchain_core.tools import tool from medox.pipeline.config_pipeline import PipelineSettings @tool def <tool_name>(<param>: str) -> str: """ <What this tool does — written for the LLM, not a human developer.> Include: - What the parameter means and expected format - Example values or class names the LLM should pass - What the tool returns and how to interpret it Example: pass 'ANTIVITAMINES K' for warfarine, 'STATINES' for simvastatine. """ settings = PipelineSettings() # ... implementation -
Register the tool in
:src/medox/agent/graph_agent.py- Add the import
- Add to the
list passed totools = [...]build_agent()
-
Docstring rules (critical — the LLM uses this to decide when/how to call the tool):
- Written in English
- Explain when to use this tool vs other tools
- Give concrete input examples (especially for ANSM class names)
- Describe the return format
-
Write the test at
:tests/agent/test_tool_<name>.pydef test_<tool_name>_returns_expected(): result = <tool_name>.invoke({"<param>": "<known_value>"}) assert "<expected_substring>" in result def test_<tool_name>_handles_unknown(): result = <tool_name>.invoke({"<param>": "nonexistent_xyz"}) assert result # returns graceful message, not exception -
Update
— add the tool to the tools table..claude/rules/agent.md -
Validate:
uv run pytest tests/agent/test_tool_<name>.py -v uv run pytest tests/agent/ -v
Rules
- Tool file name:
— matches thetool_<name>.py
function name@tool - One
per file@tool - Never raise exceptions — return a descriptive string on error
- Requires Docker stack running for ChromaDB/PostgreSQL tools