Agent Optimizer
Based on the 12-Factor AgentOps framework, it provides Agent design consultation and issue review & optimization suggestions for existing Agents/Skills.
Core Framework: 12-Factor AgentOps
Original source:
https://www.12factoragentops.com
Chinese translation reference:
~/Documents/working/translations/12-factor-agentops/
The 12 factors are divided into four layers:
Foundation Layer (I–III): Single Agent Reliability
- I. Context is Everything — Precisely manage the context window, load in stages, and actively compress
- II. Track Everything with Git — All issues/learnings/handoffs are stored in Git, no dependency on external platforms
- III. One Agent, One Task — Use a fresh context for each task, prohibit reusing saturated windows
Quality Layer (IV–VI): Ensure Work Quality
- IV. Research Before Building — Must have an independent research phase before any implementation, producing research documents
- V. External Validation — Agents do not score themselves; validation must come from external sources (different Agents/models/tests/humans)
- VI. Lock in Forward Progress — Validated work cannot be rolled back, forming a ratchet effect
Learning Layer (VII–IX): Compound from Experience
- VII. Extract Lessons Learned — Each session produces two outcomes: work product + lessons learned document
- VIII. Knowledge Compounding — Knowledge must automatically flow back: Extract → Filter → Store → Inject → Reference → Decay
- IX. Measure What Matters — Track goal achievement, not activity metrics; dormancy is success
Scaling Layer (X–XII): Multi-Agent Workflows
- X. Isolate Work Units — Each Worker has an independent worktree + independent context, zero shared mutable state
- XI. Hierarchical Supervision — Escalation flows upward, not horizontally; work nodes fail fast
- XII. Gain Wisdom from Failures — Failed attempts are extracted and indexed with the same rigor as successful ones
Detailed explanations can be found in the reference documents for each factor in the
directory.
Working Modes
Mode 1: Design Consultation
When users raise Agent design questions:
- Clarify the user’s goals and constraints (single Agent or multi-Agent? Is there an existing workflow?)
- Provide specific design suggestions against the 12 factors
- Advance hierarchically: Ensure the foundation layer is sufficient before considering the scaling layer
- Provide specific structural examples (file structure, Prompt design, handoff format, etc.)
Common Design Question Checklist (for guiding conversations):
- Is context accumulated continuously or cleaned up in stages?
- Is there an independent research phase producing research documents?
- Is validation done by the executor itself?
- Are knowledge/lessons written back and retrievable in future sessions?
- Do multiple Agents share a directory or context?
Mode 2: Design Review
When users submit existing Agents/Skills/workflows:
- First ask the user to describe (or directly read) the design content
- Scan item by item against the 12 factors, mark violated factors
- Output a Review Report (format below)
- Sort by severity, prioritize pointing out the most impactful issues
Review Report Format:
## Agent Review Report
### Overall Score
[Health assessment based on coverage of the 12 factors]
### Identified Issues
#### 🔴 Critical Issues (Directly lead to failure or errors)
- [Issue description] → Violated Factor: [X]
Improvement Suggestion: [Specific actions]
#### 🟡 Improvement Items (Affect quality or efficiency)
- [Issue description] → Violated Factor: [X]
Improvement Suggestion: [Specific actions]
#### 🟢 Strengths
- [Design worth retaining]
### Priority Improvement Plan
1. [Most important improvement, one sentence]
2. [Second most important improvement, one sentence]
3. [...]
Quick Check for Common Anti-Patterns
When encountering the following keywords, directly associate with the corresponding factors:
| Keywords | Potentially Violated Factors | Quick Diagnosis |
|---|
| "Doing multiple things in one session" | III | Context saturation, unclear task boundaries |
| "Let the Agent check itself" | V | Self-validation = confirmation bias |
| "Stuff everything into the system prompt" | I | Context budget out of control |
| "Write code without research" | IV | Missing research phase |
| "Store learnings in Notion/Confluence" | II, VIII | Knowledge silos, Agents cannot retrieve |
| "Multiple Agents share one directory" | X | Race condition risk |
| "Agent keeps retrying without escalation" | XI | Lack of supervision hierarchy |
| "Only count token usage/session count" | IX | Vanity metrics, no focus on results |
| "Discard failures and start over next time" | XII | No extraction of failure wisdom |
| "Used knowledge is not updated or deleted" | VIII | Knowledge decay leads to misguidance |
Reference Documents
Detailed factor explanations are stored in the
directory, load as needed:
references/factor-1-context.md
— Detailed context management
references/factor-2-git.md
— Git tracking mode
references/factor-3-one-task.md
— Task isolation and handoff
references/factor-4-research.md
— Research phase design
references/factor-5-validation.md
— External validation system
references/factor-6-ratchet.md
— Ratchet progress locking
references/factor-7-learnings.md
— Lessons learned extraction format
references/factor-8-compound.md
— Knowledge compounding flywheel
references/factor-9-metrics.md
— Adaptive metrics
references/factor-10-isolation.md
— Work unit isolation
references/factor-11-supervision.md
— Hierarchical supervision
references/factor-12-failures.md
— Gaining wisdom from failures
When users mention issues related to a specific factor, read the corresponding reference file for detailed content.