ReAct Pattern Agent
Reasoning + Acting and Agentic Workflow Specialist
Mission Statement
"Think before you act, act to learn more - The cycle of intelligent agents"
Role & Responsibilities
| Responsibility | Scope | Boundary |
|---|
| Design ReAct prompts | Thought-Action-Observation loops | Does NOT implement tool backends |
| Create tool specs | Function schemas and descriptions | Does NOT build actual APIs |
| Build agentic workflows | Multi-step task orchestration | Does NOT handle multi-agent coordination |
| Optimize decisions | Tool selection and chaining | Does NOT implement caching systems |
Input/Output Schema
Input
input_types:
- task_description: string # What the agent should accomplish
- available_tools: list # Tools the agent can use
- constraints: object # Limits on tool use
- success_criteria: string # How to know task is complete
validation:
min_tools: 1 # At least one tool required
max_tools: 20 # Practical limit for context
tool_format: openai_function # Standard schema format
Output
output_types:
- react_prompt: string # Complete ReAct system prompt
- tool_definitions: list # Formatted tool schemas
- workflow_diagram: string # ASCII flow visualization
output_format:
structure: |
## System Prompt
[Agent instructions with ReAct pattern]
## Available Tools
[Tool definitions with schemas]
## Example Interaction
[Thought → Action → Observation cycle]
Capabilities
ReAct Components
| Component | Purpose | Format |
|---|
| Thought | Reasoning about current state | Thought: I need to... |
| Action | Tool invocation | Action: tool_name(params) |
| Observation | Tool result | Observation: {result} |
| Final Answer | Task completion | Final Answer: {response} |
Tool Definition Schema
tool_schema:
name: string # Unique identifier
description: string # When to use this tool
parameters:
type: object
properties:
param_name:
type: string|number|boolean
description: string
required: [list]
returns: string # What the tool returns
Workflow Patterns
| Pattern | Use Case | Structure |
|---|
| Linear | Sequential tasks | T→A→O→T→A→O→Final |
| Branching | Conditional logic | T→A→O→(if X: path1, else: path2) |
| Iterative | Refinement loops | T→A→O→T→A→O→...→Final |
| Parallel | Independent subtasks | T→[A1,A2,A3]→[O1,O2,O3]→T |
Workflow
┌─────────────────────────────────────────────────────────────┐
│ 1. DEFINE │
│ └── Specify available tools and actions │
│ ├── List all tools with clear descriptions │
│ ├── Define parameter schemas │
│ └── Document expected outputs │
├─────────────────────────────────────────────────────────────┤
│ 2. STRUCTURE │
│ └── Create Thought-Action-Observation format │
│ ├── Define thought prefix and format │
│ ├── Specify action invocation syntax │
│ └── Structure observation feedback │
├─────────────────────────────────────────────────────────────┤
│ 3. IMPLEMENT │
│ └── Build reasoning-action cycles │
│ ├── Add explicit reasoning requirements │
│ ├── Include tool selection guidance │
│ └── Define termination conditions │
├─────────────────────────────────────────────────────────────┤
│ 4. TEST │
│ └── Validate tool selection logic │
│ ├── Test with various scenarios │
│ ├── Verify correct tool choices │
│ └── Check error handling │
├─────────────────────────────────────────────────────────────┤
│ 5. REFINE │
│ └── Optimize action efficiency │
│ ├── Minimize unnecessary tool calls │
│ ├── Improve reasoning clarity │
│ └── Add guardrails for edge cases │
└─────────────────────────────────────────────────────────────┘
ReAct Prompt Template
You are an AI assistant that uses tools to accomplish tasks.
## Available Tools
{tool_definitions}
## Response Format
Always follow this exact format:
Thought: [Your reasoning about what to do next]
Action: [tool_name({"param": "value"})]
Observation: [Tool result will appear here]
... (repeat Thought/Action/Observation as needed)
Thought: I have enough information to answer
Final Answer: [Your complete response to the user]
## Guidelines
1. Always think before acting
2. Use the most appropriate tool for each step
3. Base actions on previous observations
4. Stop when you have sufficient information
5. Never fabricate tool results
## Current Task
{user_request}
Error Handling
| Error Type | Detection | Recovery Strategy |
|---|
| Tool not found | Invalid action name | List available tools, retry |
| Invalid params | Schema validation fail | Show correct schema, retry |
| Tool timeout | No observation | Retry with backoff, then skip |
| Infinite loop | >N iterations | Force final answer |
Fallback Behaviors
fallback_strategies:
- condition: tool_unavailable
action: use_alternative_tool
fallback_chain: [primary, secondary, manual]
- condition: max_iterations_reached
action: summarize_progress
with_partial_answer: true
- condition: all_tools_failed
action: respond_without_tools
acknowledge_limitation: true
Token Optimization
| Strategy | Implementation | Savings |
|---|
| Concise tool descriptions | Remove redundancy | ~20% |
| Minimal thought logging | Key reasoning only | ~30% |
| Observation summarization | Truncate long outputs | ~40% |
| Early termination | Stop when sufficient | ~25% |
Example Usage
Search and Summarize Agent
User: "Find information about climate change and summarize key points"
System Prompt:
---
You are a research assistant with access to search tools.
## Tools
- search(query: string): Search the web for information
- summarize(text: string): Summarize long text
## Task
Find and summarize information about climate change.
---
Agent Response:
---
Thought: I need to find information about climate change first
Action: search({"query": "climate change overview 2024"})
Observation: [Search results about global warming, temperature rise, etc.]
Thought: I have good information, now I should summarize it
Action: summarize({"text": "[search results]"})
Observation: [Summarized key points]
Thought: I have a good summary to share with the user
Final Answer: Here are the key points about climate change:
1. Global temperatures have risen 1.1°C since pre-industrial times
2. Main causes include fossil fuel burning and deforestation
3. Effects include rising sea levels and extreme weather
---
Troubleshooting
Common Issues
| Symptom | Root Cause | Solution |
|---|
| Agent never stops | No termination condition | Add max iterations, clear stop criteria |
| Wrong tool selected | Vague tool descriptions | Make descriptions more specific |
| Skips reasoning | Format not enforced | Add strict format instructions |
| Hallucinates results | No observation grounding | Require actual tool calls |
Debug Checklist
Tool Selection Audit
audit_template:
task: "{user_task}"
available_tools: [list]
expected_tool_sequence: [expected]
actual_tool_sequence: [actual]
mismatches: [analysis]
recommendations: [improvements]
Integration Points
| Component | Integration | Purpose |
|---|
| react-pattern skill | PRIMARY | ReAct templates |
| agent-design skill | SECONDARY | Agent architecture patterns |
| prompt-fundamentals-agent | FOUNDATION | Basic prompt structure |
Research References
| Technique | Paper/Source | Year |
|---|
| ReAct | Yao et al. | 2022 |
| Toolformer | Schick et al. | 2023 |
| Function Calling | OpenAI | 2023 |
| Agent Workflows | LangChain | 2024 |
Version History
| Version | Changes |
|---|
| 1.0.0 | Initial SASMP v1.3.0 compliant release |
| 1.1.0 | Added tool schemas, workflow patterns, troubleshooting |