VibecoderMcSwaggins commited on
Commit
c7a2e77
Β·
1 Parent(s): 3a8b0e5

docs: Audit and fix architecture documentation for accuracy

Browse files

Verified all architecture docs against actual codebase:

- component-inventory.md: Fixed RetrievalAgent (it's a factory function,
not a class) and WebSearchTool (added dead code warning per issue #134)

- overview.md: Added Status column to Agents table, added RetrievalAgent
with "Not wired" status (see #134)

- agent-tool-state-contracts.md: Added dead code warning for RetrievalAgent
explaining it's implemented but not wired into magentic_agents.py

- workflow-diagrams.md: Fixed Implementation Highlights to show actual
factory pattern (not fake MagenticBuilder code), updated footer to
distinguish Active Agents (4) from Implemented but Not Wired (1)

- production-readiness.md: Removed timeline estimates from Next Steps
sections per style guidelines

All verified against:
- src/agents/magentic_agents.py (factory functions)
- src/agents/retrieval_agent.py (create_retrieval_agent, search_web)
- src/agents/tools.py (line numbers verified)
- src/utils/exceptions.py (exception hierarchy verified)
- src/utils/models.py (data models verified)

docs/architecture/agent-tool-state-contracts.md CHANGED
@@ -54,6 +54,10 @@ This document defines the exact contracts between agents, tools, and shared stat
54
  | **ReportAgent** | `magentic_agents.py` | Report synthesis | get_bibliography |
55
  | **RetrievalAgent** | `retrieval_agent.py` | Web search | search_web |
56
 
 
 
 
 
57
  ---
58
 
59
  ## Agent Contracts
 
54
  | **ReportAgent** | `magentic_agents.py` | Report synthesis | get_bibliography |
55
  | **RetrievalAgent** | `retrieval_agent.py` | Web search | search_web |
56
 
57
+ > **⚠️ Dead Code Warning:** RetrievalAgent is implemented but NOT wired into `magentic_agents.py`.
58
+ > The orchestrator only uses SearchAgent (PubMed, ClinicalTrials, EuropePMC), not web search.
59
+ > See GitHub issue #134 for decision to delete or wire in.
60
+
61
  ---
62
 
63
  ## Agent Contracts
docs/architecture/component-inventory.md CHANGED
@@ -170,7 +170,10 @@ else:
170
  ### `retrieval_agent.py`
171
  | Component | Type | Description |
172
  |-----------|------|-------------|
173
- | `RetrievalAgent` | Class | Evidence retrieval coordination |
 
 
 
174
 
175
  ### `hypothesis_agent.py`
176
  | Component | Type | Description |
@@ -292,7 +295,9 @@ else:
292
  ### `web_search.py`
293
  | Component | Type | Description |
294
  |-----------|------|-------------|
295
- | Web search | Module | DuckDuckGo integration |
 
 
296
 
297
  ---
298
 
 
170
  ### `retrieval_agent.py`
171
  | Component | Type | Description |
172
  |-----------|------|-------------|
173
+ | `create_retrieval_agent()` | Factory | Creates ChatAgent for web search |
174
+ | `search_web` | @ai_function | DuckDuckGo web search tool |
175
+
176
+ > **Note:** This module is implemented but NOT wired into `magentic_agents.py`. See GitHub issue #134.
177
 
178
  ### `hypothesis_agent.py`
179
  | Component | Type | Description |
 
295
  ### `web_search.py`
296
  | Component | Type | Description |
297
  |-----------|------|-------------|
298
+ | `WebSearchTool` | Class | DuckDuckGo integration wrapper |
299
+
300
+ > **Note:** Used by `search_web` in `retrieval_agent.py`. See GitHub issue #134 for dead code status.
301
 
302
  ---
303
 
docs/architecture/overview.md CHANGED
@@ -161,12 +161,13 @@ def get_chat_client():
161
 
162
  ### Agents (`src/agents/`)
163
 
164
- | Agent | File | Role |
165
- |-------|------|------|
166
- | SearchAgent | `search_agent.py` | Evidence retrieval |
167
- | JudgeAgent | `judge_agent.py` | Evidence evaluation |
168
- | ReportAgent | `report_agent.py` | Report synthesis |
169
- | HypothesisAgent | `hypothesis_agent.py` | Mechanistic pathway analysis |
 
170
 
171
  ### Tools (`src/tools/`)
172
 
 
161
 
162
  ### Agents (`src/agents/`)
163
 
164
+ | Agent | File | Role | Status |
165
+ |-------|------|------|--------|
166
+ | SearchAgent | `search_agent.py` | Evidence retrieval | βœ… Active |
167
+ | JudgeAgent | `judge_agent.py` | Evidence evaluation | βœ… Active |
168
+ | ReportAgent | `report_agent.py` | Report synthesis | βœ… Active |
169
+ | HypothesisAgent | `hypothesis_agent.py` | Mechanistic pathway analysis | βœ… Active |
170
+ | RetrievalAgent | `retrieval_agent.py` | Web search (DuckDuckGo) | ⚠️ Not wired (see #134) |
171
 
172
  ### Tools (`src/tools/`)
173
 
docs/architecture/production-readiness.md CHANGED
@@ -323,22 +323,22 @@ None. The system is functional for demo/research use.
323
 
324
  ## Next Steps (If Going to Production)
325
 
326
- ### Phase 1: Observability (2-3 weeks)
327
  1. Add OpenTelemetry instrumentation
328
  2. Emit trace IDs in AgentEvents
329
  3. Add token counting to LLM clients
330
 
331
- ### Phase 2: Safety (1-2 weeks)
332
  1. Add input validation layer
333
  2. Implement prompt injection detection
334
  3. Add confidence thresholds for escalation
335
 
336
- ### Phase 3: Resilience (1-2 weeks)
337
  1. Add per-tool circuit breakers
338
  2. Improve rate limit handling
339
  3. Add health checks
340
 
341
- ### Phase 4: Evaluation (2-4 weeks)
342
  1. Create evaluation datasets
343
  2. Implement meta-evaluation of Judge
344
  3. Establish quality baselines
 
323
 
324
  ## Next Steps (If Going to Production)
325
 
326
+ ### Phase 1: Observability
327
  1. Add OpenTelemetry instrumentation
328
  2. Emit trace IDs in AgentEvents
329
  3. Add token counting to LLM clients
330
 
331
+ ### Phase 2: Safety
332
  1. Add input validation layer
333
  2. Implement prompt injection detection
334
  3. Add confidence thresholds for escalation
335
 
336
+ ### Phase 3: Resilience
337
  1. Add per-tool circuit breakers
338
  2. Improve rate limit handling
339
  3. Add health checks
340
 
341
+ ### Phase 4: Evaluation
342
  1. Create evaluation datasets
343
  2. Implement meta-evaluation of Judge
344
  3. Establish quality baselines
docs/architecture/workflow-diagrams.md CHANGED
@@ -640,39 +640,36 @@ gantt
640
 
641
  ## Implementation Highlights
642
 
643
- **Simple 4-Agent Setup:**
644
  ```python
645
- workflow = (
646
- MagenticBuilder()
647
- .participants(
648
- hypothesis=HypothesisAgent(tools=[background_tool]),
649
- search=SearchAgent(tools=[web_search, rag_tool]),
650
- analysis=AnalysisAgent(tools=[code_execution]),
651
- report=ReportAgent(tools=[code_execution, visualization])
652
- )
653
- .with_standard_manager(
654
- chat_client=AnthropicClient(model="claude-sonnet-4"),
655
- max_round_count=15, # Prevent infinite loops
656
- max_stall_count=3 # Detect stuck workflows
657
- )
658
- .build()
659
- )
660
  ```
661
 
662
  **Current Agent Capabilities:**
663
- - **HypothesisAgent**: Generates research hypotheses
664
  - **SearchAgent**: Multi-source search (PubMed, ClinicalTrials, Europe PMC)
665
  - **JudgeAgent**: Evaluates evidence quality, determines sufficiency
666
- - **ReportAgent**: Generates final research report
667
- - **RetrievalAgent**: Web search via DuckDuckGo
 
668
 
669
  **Manager** (AdvancedOrchestrator) coordinates agent execution and workflow.
670
 
671
  ---
672
 
673
- **Document Version**: 2.1 (Revised for accuracy)
674
  **Last Updated**: 2025-12-06
675
  **Architecture**: Microsoft Magentic Orchestration Pattern
676
- **Implemented Agents**: 5 (Hypothesis, Search, Judge, Report, Retrieval) + Manager
677
- **Planned but Not Implemented**: Analysis Agent (code execution removed in PR #130)
 
678
  **License**: MIT
 
640
 
641
  ## Implementation Highlights
642
 
643
+ **Actual Agent Factory Pattern (from `magentic_agents.py`):**
644
  ```python
645
+ # Create agents via factory functions
646
+ search_agent = create_search_agent(chat_client, domain, api_key)
647
+ judge_agent = create_judge_agent(chat_client, domain, api_key)
648
+ hypothesis_agent = create_hypothesis_agent(chat_client, domain, api_key)
649
+ report_agent = create_report_agent(chat_client, domain, api_key)
650
+
651
+ # Each agent is a ChatAgent with specific tools:
652
+ # - SearchAgent: search_pubmed, search_clinical_trials, search_preprints
653
+ # - JudgeAgent: None (LLM-only evaluation)
654
+ # - HypothesisAgent: None (LLM-only generation)
655
+ # - ReportAgent: get_bibliography
 
 
 
 
656
  ```
657
 
658
  **Current Agent Capabilities:**
 
659
  - **SearchAgent**: Multi-source search (PubMed, ClinicalTrials, Europe PMC)
660
  - **JudgeAgent**: Evaluates evidence quality, determines sufficiency
661
+ - **HypothesisAgent**: Generates research hypotheses
662
+ - **ReportAgent**: Generates final research report with bibliography
663
+ - **RetrievalAgent**: Web search via DuckDuckGo (⚠️ NOT wired in - see issue #134)
664
 
665
  **Manager** (AdvancedOrchestrator) coordinates agent execution and workflow.
666
 
667
  ---
668
 
669
+ **Document Version**: 2.2 (Audited for accuracy)
670
  **Last Updated**: 2025-12-06
671
  **Architecture**: Microsoft Magentic Orchestration Pattern
672
+ **Active Agents**: 4 (Search, Judge, Hypothesis, Report) + Manager
673
+ **Implemented but Not Wired**: RetrievalAgent (see issue #134)
674
+ **Planned but Not Implemented**: AnalysisAgent (code execution removed in PR #130)
675
  **License**: MIT