Agentic Prompt Architecture
Multi-Step Reasoning Patterns
Production AI agents use sophisticated reasoning patterns to solve complex problems. These patterns—ReAct, Chain-of-Thought, and Tree-of-Thought—appear throughout real system prompts.
ReAct Pattern (Reasoning + Acting)
The most common pattern in agentic systems:
ReAct Framework:
For each step in solving a problem:
1. THOUGHT: Analyze current situation
- What do I know?
- What do I need to find out?
- What's the best next action?
2. ACTION: Execute a specific action
- Use available tools
- Gather information
- Make changes
3. OBSERVATION: Process the results
- What did I learn?
- Did it work as expected?
- Do I need to adjust?
Repeat until task is complete or blocked.
ReAct in Claude Code
From Claude Code's system prompt:
When solving problems:
1. Understand the task requirements
2. Search for relevant code using Glob/Grep
3. Read files to understand context
4. Plan your approach
5. Execute changes incrementally
6. Verify each change works
7. Run tests to confirm
Never modify code you haven't read.
ReAct in Cursor
Cursor's agent mode implements ReAct:
Agent Mode Reasoning:
- Analyze user request
- Search codebase for context
- Identify files to modify
- Make targeted changes
- Validate changes compile
- Run relevant tests
- Report results
Chain-of-Thought (CoT)
Explicit step-by-step reasoning:
Chain-of-Thought Prompt:
When solving complex problems, think step by step:
Step 1: Understand the problem completely
- Restate the problem in your own words
- Identify inputs, outputs, constraints
Step 2: Break into subproblems
- What are the major components?
- What order should they be solved?
Step 3: Solve each subproblem
- Work through each component
- Document your reasoning
Step 4: Combine solutions
- How do parts fit together?
- Are there integration issues?
Step 5: Verify the solution
- Does it meet all requirements?
- Are there edge cases?
CoT in GPT-5.2 Thinking Mode
GPT-5.2 Thinking variant uses explicit CoT:
GPT-5.2 Thinking Mode:
<thinking>
Let me work through this step by step:
1. First, I need to understand what the user is asking...
2. The key constraints are...
3. I'll approach this by...
4. Potential issues include...
5. My solution will...
</thinking>
Based on my analysis, here's my recommendation...
CoT in Gemini 3
Gemini 3 Flash implements "Deep Think" mode:
Deep Think Activation:
When complex reasoning is needed:
- Pause before responding
- Break problem into logical steps
- Consider multiple approaches
- Evaluate tradeoffs
- Select best solution
- Explain reasoning clearly
Tree-of-Thought (ToT)
Exploring multiple solution paths:
Tree-of-Thought Pattern:
For complex decisions, explore multiple branches:
Problem: {{problem_statement}}
Branch A: Approach 1
├── Pros: ...
├── Cons: ...
└── Estimated success: 70%
Branch B: Approach 2
├── Pros: ...
├── Cons: ...
└── Estimated success: 60%
Branch C: Approach 3
├── Pros: ...
├── Cons: ...
└── Estimated success: 85%
Selected: Branch C
Reasoning: Highest success probability, acceptable tradeoffs
ToT in Devin's Planning
Devin 2.0 uses ToT for architecture decisions:
Architecture Decision:
Task: Add authentication to API
Option 1: JWT tokens
- Stateless
- Scalable
- Complexity: Medium
Option 2: Session cookies
- Familiar pattern
- Server state required
- Complexity: Low
Option 3: OAuth 2.0
- Industry standard
- External providers
- Complexity: High
Recommendation: JWT tokens
- Matches existing stateless architecture
- Team has experience
- Scalable for future needs
Structured Output Reasoning
Many agents use structured formats:
Structured Reasoning Template:
<analysis>
<understanding>
What I understood from the request...
</understanding>
<approach>
How I plan to solve this...
</approach>
<risks>
What could go wrong...
</risks>
<decision>
What I decided to do and why...
</decision>
</analysis>
XML Reasoning in Claude
Claude models use XML for structured thought:
Claude Reasoning Pattern:
<scratchpad>
Let me analyze this request:
- User wants to refactor the auth module
- Current code uses callbacks
- Should migrate to async/await
- Need to maintain backwards compatibility
</scratchpad>
<plan>
1. Identify all callback-based functions
2. Create async versions alongside existing
3. Add deprecation notices to old functions
4. Update tests for new implementations
5. Document migration path
</plan>
Iterative Refinement
Production agents refine solutions:
Iterative Refinement Protocol:
1. Generate initial solution
2. Self-critique the solution
- What's missing?
- What could be better?
- What are the edge cases?
3. Improve based on critique
4. Repeat until satisfactory
Max iterations: 3
Quality threshold: 80%
Refinement in v0
v0's UI generation uses iterative refinement:
v0 Refinement Loop:
1. Generate initial component
2. Check against design system
3. Validate accessibility
4. Verify responsive behavior
5. Optimize performance
6. Refine until meets standards
Standards:
- shadcn/ui compliance
- WCAG 2.1 AA
- Core Web Vitals pass
Combining Patterns
Production systems combine patterns:
Hybrid Reasoning (Cursor Agent):
1. ReAct for task execution
- Think about next action
- Execute action
- Observe results
2. CoT for complex decisions
- Step-by-step analysis
- Document reasoning
3. ToT for architecture choices
- Explore alternatives
- Select best approach
4. Iterative refinement
- Generate solution
- Self-critique
- Improve
Pattern Selection Guidelines
When to use each pattern:
| Pattern | Best For | Example |
|---|---|---|
| ReAct | Multi-step tasks | Debugging, refactoring |
| CoT | Complex reasoning | Algorithm design |
| ToT | Decision making | Architecture choices |
| Iterative | Quality improvement | UI generation |
Key Insight: Production agents don't use just one reasoning pattern. They combine ReAct for action, CoT for analysis, ToT for decisions, and iterative refinement for quality. The prompt architecture orchestrates these patterns based on task requirements.
Next, we'll explore self-correction and error recovery patterns. :::