dspy-codeact
Installation
SKILL.md
Build Agents That Write and Execute Code with dspy.CodeAct
Guide the user through building DSPy agents that solve problems by generating and running Python code, rather than calling tools through a fixed interface.
What is CodeAct
dspy.CodeAct is a DSPy module that creates agents which write Python code to accomplish tasks. Instead of selecting from a predefined set of tool calls (like ReAct), CodeAct generates executable code snippets that use provided tools as Python functions.
The agent works in a loop:
- Generate -- the LM writes a Python code snippet using the available tools
- Execute -- the code runs in a sandboxed interpreter
- Observe -- the agent sees the output and decides whether the task is done
- Repeat -- if not done, writes more code incorporating previous results
CodeAct inherits from both ReAct and ProgramOfThought, combining reasoning-and-acting with code generation.