# Knowledge Base: Agent 4 — The Digital Vice President

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

---

## 1. 3-Tier Agentic Memory Management Schema

Agent 4 uses `save_memory` and `retrieve_memory` tool calls to maintain state across three distinct tiers:

```json
{
  "short_term_memory": {
    "active_deal_id": "Project Vantage",
    "target_company": "Apex Technologies Corp",
    "ticker": "APEX",
    "current_stage": "Stage 4 - HITL MD Sign-Off",
    "deal_parameters": { "entry_ev": 4500.0, "debt_pct": 0.60, "hold_period": 5 }
  },
  "long_term_memory": {
    "sector_benchmarks": {
      "Enterprise_SaaS": { "avg_ev_ebitda": "11.8x", "avg_margin": "28.5%" },
      "Healthcare_IT": { "avg_ev_ebitda": "10.5x", "avg_margin": "24.0%" }
    }
  },
  "procedural_memory": {
    "md_sarah_jenkins": {
      "synergy_waterfall_slide_index": 3,
      "debt_assumption_bias": "Conservative 60/40 Debt/Equity",
      "preferred_theme": "Dark Slate",
      "required_disclaimer": "CONFIDENTIAL - BOARD PRESENTATION ONLY"
    }
  }
}
```

---

## 2. Master Loop Controller State Machine

```
[MD Input: High-Level Business Goal]
                │
                ▼
  [Plan Generation & Task Decomposition]
                │
                ├──► Thread 1: Agent 1 (Data Ingestion & SQL)
                └──► Thread 2: Agent 2 (Financial Modeling & CIM)
                │
                ▼
    [Dynamic Error Monitor & MCP Rerouting]
                │
                ▼
     [Stage 3: Agent 3 Compliance Audit]
                │
                ▼
  [Stage 4: Strategic Framing & Executive Briefing]
                │
                ▼
  [Pause Execution -> Present Decision Dashboard for HITL]
```

---

## 3. Dynamic Rerouting Exception Mapping

| Exception Encountered | Initial Source | Dynamic Reroute Action |
| :--- | :--- | :--- |
| Primary SEC URL 404 Error | EDGAR Web Scraper | Reroute Agent 1 to query secondary SEC database via MCP |
| Unformatted Earnings Transcript | Web Scraping API | Reroute Agent 1 to parse unstructured PDF text chunks |
| Missing Peer Comps Ticker | Live Market Feed | Retrieve sector benchmark averages from Long-Term Memory |
