# Knowledge Base: Agent 5 — The Chief of Staff Agent

> **Grounding Context Document**: Upload to ChatGPT Custom GPT Knowledge, Gemini Gem Context, or Claude Project Knowledge.

---

## 1. State Machine Dynamic Routing Matrix (States 1 - 4)

| State Code | System State Trigger | Target Worker Agent | Primary Directive Prompt |
| :--- | :--- | :--- | :--- |
| `STATE-1` | **Information Gap** | Agent 1 (Prospector) | `"Extract trailing 3-yr financials, scrape alternative data, return JSON."` |
| `STATE-2` | **Production Required** | Agent 2 (Production) | `"Build 40-tab LBO model using Agent 1 data, run downside scenario (-15% Rev)."` |
| `STATE-3` | **Strategic Framing** | Agent 4 (Digital VP) | `"Draft CIM deck and executive email framing narrative for client leverage profile."` |
| `STATE-4` | **Risk Alert / Review** | Agent 3 (Compliance)| `"Perform full factual audit on Agent 2 model and Agent 4 CIM. Screen for MNPI."` |

---

## 2. DPPM (Decompose, Plan, and Merge) Workflow Framework

```json
{
  "dppm_framework": {
    "macro_objective": "Prepare Buyout Feasibility & Defense Plan",
    "decomposition_rules": [
      { "task_id": "T1", "type": "DATA_DISCOVERY", "agent": "Agent 1", "dependencies": [] },
      { "task_id": "T2", "type": "FINANCIAL_MODELING", "agent": "Agent 2", "dependencies": ["T1"] },
      { "task_id": "T3", "type": "STRATEGIC_NARRATIVE", "agent": "Agent 4", "dependencies": ["T2"] },
      { "task_id": "T4", "type": "COMPLIANCE_AUDIT", "agent": "Agent 3", "dependencies": ["T2", "T3"] }
    ],
    "merging_protocol": "Synthesize verified T1-T4 outputs into single Decision Brief for Chairman/MD."
  }
}
```

---

## 3. Dynamic Model Routing & Cost Optimization Engine

To cut API token consumption by up to 60%, Agent 5 applies dynamic model assignment rules:

| Task Tier | Task Complexity | Assigned Model Tier | Cost Benchmark |
| :--- | :--- | :--- | :--- |
| **Tier 1: Data Parsing** | Basic ETL, JSON Extraction | Fast / Utility Model (e.g. GPT-4o-mini / Flash) | 90% Savings |
| **Tier 2: Financial Modeling** | Deterministic Formula Writing | Standard Reasoning Model | 50% Savings |
| **Tier 3: Compliance & Audit** | Zero-Hallucination EDGAR Audit | High-Precision Compliance Model | Standard |
| **Tier 4: Meta-Orchestration** | Strategic Framing, Conflict Debate | Frontier Reasoning Model (e.g. O1 / Opus) | Reserved for High-Value |

---

## 4. Meta-Optimization System Evolution Protocol

Agent 5 periodically performs self-diagnosis and rule updating:
1. Ingest trajectory logs across past 20 deal executions.
2. Calculate bottleneck metrics: Average revision cycles between Agent 2 and Agent 3.
3. If revision cycles > 3.0, update Agent 2's `PROMPT.md` System Instructions with stricter pre-computation rules.
4. Log evolution event: `[META-OPTIMIZATION]: Prompt rules updated autonomously for Agent 2.`
