Skip to content

plan-execute

plan-execute separates thinking from doing: first create a structured plan, then execute each step, then verify the result. If verification fails, the loop repeats.

  • Complex tasks that benefit from upfront planning
  • Multi-step workflows with verifiable outcomes
  • Tasks where the execution order matters
  • Code generation and testing loops
agents/my-plan-execute/
├── AGENT.md ← pattern: plan-execute, config
├── execute.md ← execute one step from the plan
└── verify.md ← verify the current result
---
name: project-builder
description: Plans and executes a multi-step project.
version: "1.0.0"
pattern: plan-execute
max_iter: 5
call:
model:
role: thinker
---
You are a project planner. Given a task, create a detailed execution plan.
Output a JSON array of steps:
[
{"step": 1, "action": "...", "expected_output": "..."},
{"step": 2, "action": "...", "expected_output": "..."}
]
Call finish with key="done" and the JSON plan as value.
---
call:
model:
role: thinker
uses:
- search-web
---
You receive a plan and the current execution state.
Execute the next pending step. Record what you did and what you produced.
Update the plan state to mark the step as complete.
Call finish with key="done" and the updated execution state as value.
You receive the completed execution state.
Check:
1. All steps were executed
2. Each step's output matches its expected output
3. The overall goal is achieved
If everything is complete and correct, call finish with key="DONE".
If steps need to be retried or the plan needs adjustment, call finish with key="RETRY" and describe what needs to change.
Terminal window
tama add plan-execute my-agent
AGENT.md body → create JSON plan
execute.md → execute next step, update state
verify.md → check results
→ key="DONE": return final result
→ key="RETRY": loop back to execute
(repeat up to max_iter times)

The verify step controls the loop:

  • finish(key="DONE", value=<result>) — all steps complete, return result
  • finish(key="RETRY", value=<feedback>) — something failed, loop back with feedback