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.
When to use it
Section titled “When to use it”- Complex tasks that benefit from upfront planning
- Multi-step workflows with verifiable outcomes
- Tasks where the execution order matters
- Code generation and testing loops
File structure
Section titled “File structure”agents/my-plan-execute/├── AGENT.md ← pattern: plan-execute, config├── execute.md ← execute one step from the plan└── verify.md ← verify the current resultAGENT.md
Section titled “AGENT.md”---name: project-builderdescription: Plans and executes a multi-step project.version: "1.0.0"pattern: plan-executemax_iter: 5call: 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.execute.md
Section titled “execute.md”---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.verify.md
Section titled “verify.md”You receive the completed execution state.
Check:1. All steps were executed2. Each step's output matches its expected output3. 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.Scaffold
Section titled “Scaffold”tama add plan-execute my-agentHow it works
Section titled “How it works”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)DONE and RETRY
Section titled “DONE and RETRY”The verify step controls the loop:
finish(key="DONE", value=<result>)— all steps complete, return resultfinish(key="RETRY", value=<feedback>)— something failed, loop back with feedback