dspy-react
Installation
SKILL.md
Build Tool-Using Agents with dspy.ReAct
Guide the user through building agents that reason step-by-step and call tools to accomplish tasks. dspy.ReAct implements the Reasoning-Action-Observation loop -- the agent thinks about what to do, calls a tool, observes the result, and repeats until it has an answer.
Gather context first
Before generating code, ask:
- What tools does the agent need? Describe what each tool does and what data source it connects to (e.g., "a web search tool that calls the Serper API", "a database lookup for user accounts by email").
- How many steps might the agent need per query? One or two lookups (simple) or multi-step research chains (complex)? This determines
max_iters. - What are the agent's inputs? Just a question, or also context like user ID, session state, or a system prompt?
- What outputs do you need? A plain answer field, or structured fields like
confidence,sources, orcategory?
What is ReAct
dspy.ReAct implements the Reasoning-Action-Observation loop as an optimizable module. The agent reasons about what to do, calls a tool, observes the result, and repeats until it has enough information to answer. DSPy handles the loop mechanics and prompt construction.