Based on Anthropic 'Building Effective Agents' and Lilian Weng's research: New Agents: - @planner: Task decomposition using CoT, ToT, Plan-Execute-Reflect - @reflector: Self-reflection using Reflexion pattern - @memory-manager: Memory systems (short/long/episodic) New Skills: - memory-systems: Memory architecture for autonomous agents - planning-patterns: CoT, ToT, ReAct, Reflexion patterns - tool-use: ACI design principles from Anthropic New Rules: - agent-patterns: Core patterns from research Updated AGENTS.md with new agent categories: - Cognitive Enhancement: planner, reflector, memory-manager - Improved workflow state machine with reflection loop Related: Issue #25 (Research Milestone)
1.8 KiB
1.8 KiB
Agent Patterns Rules
Based on research from Anthropic, OpenAI, and Lilian Weng.
Core Patterns (Anthropic)
1. Prompt Chaining
Sequential steps with validation gates.
when: Task can be cleanly decomposed
example: Generate copy, then translate
gate: Validate each step before next
2. Routing
Classify input, route to specialized agent.
when: Distinct categories, clear classification
example: Customer service routing (refunds, technical, general)
3. Parallelization
Run independent tasks simultaneously.
when: Subtasks are independent
types:
- Sectioning: Break into parallel parts
- Voting: Multiple attempts, aggregate results
4. Orchestrator-Workers
Central controller delegates to workers.
when: Subtasks dynamic, not pre-defined
example: Coding agent editing multiple files
5. Evaluator-Optimizer
Loop: generate, evaluate, improve.
when: Clear criteria, iterative improves
example: Code review loop
Memory Architecture (Lilian Weng)
Components
- Planning: Task decomposition, self-reflection
- Memory: Short-term, long-term, episodic
- Tool Use: External APIs, code execution
Memory Types
- Sensory: Embeddings (milliseconds)
- Short-term: Context window (~4000 tokens)
- Long-term: Vector store (infinite)
- Episodic: Experience log
Tool Use Best Practices (Anthropic)
- Give model "think" space before output
- Keep formats close to internet patterns
- Minimize formatting overhead
- Invest in ACI like HCI
ReAct Pattern
Interleave reasoning and action:
Thought: [reasoning]
Action: [tool call]
Observation: [result]
(Repeat until done)
Reflexion Pattern
Learn from mistakes:
1. Take action
2. Check heuristic
3. Generate reflection
4. Update memory
5. Retry with lesson