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:

  1. Generate -- the LM writes a Python code snippet using the available tools
  2. Execute -- the code runs in a sandboxed interpreter
  3. Observe -- the agent sees the output and decides whether the task is done
  4. Repeat -- if not done, writes more code incorporating previous results

CodeAct inherits from both ReAct and ProgramOfThought, combining reasoning-and-acting with code generation.

How CodeAct differs from ReAct

Related skills

More from lebsral/dspy-programming-not-prompting-lms-skills

Installs
5
GitHub Stars
5
First Seen
Mar 17, 2026