dspy-tools
Installation
SKILL.md
Give Agents Tool-Calling Abilities with dspy.Tool
Guide the user through wrapping functions as DSPy tools, using dspy.PythonInterpreter for sandboxed code execution, and wiring tools into agents with dspy.ReAct and dspy.CodeAct.
Step 1: What kind of tool integration?
Ask the user before diving in:
- What does your tool do? Search, calculate, call an API, query a database, execute code?
- Which agent will use it? ReAct (tool calling) or CodeAct (code generation)? If unsure, start with ReAct.
- Do you need sandboxed execution? If the agent generates and runs arbitrary code, use
PythonInterpreter. Otherwise, plain tool functions are simpler.
Then jump to the relevant section below.
| Approach | Best for | Trade-off |
|---|---|---|
Function passed directly to dspy.ReAct |
Most tool use — search, lookup, API calls | Simplest; name and description come from the function itself |
dspy.Tool explicit wrap |
Override name/desc/schema; convert LangChain or MCP tools | Same runtime cost, more control over what the LM sees |
dspy.PythonInterpreter + dspy.CodeAct |
Arbitrary computation, multi-step data manipulation | Requires Deno; more powerful but harder to debug |