2.9 KiB
2.9 KiB
Implementation Summary: Modular Agentic Framework
Overview
We have successfully implemented the core Agentic Framework for the PHQ-8 assessment benchmark. This architecture uses LangGraph to orchestrate a multi-stage reasoning process ("RISEN") and supports dynamic switching between Local (Tier 1) and Cloud (Tier 3) models. The system is fully integrated with the MongoDB infrastructure for data and prompts.
Completed Components
1. Agent Architecture (src/helia/agent/graph.py)
- Implemented a
StateGraphthat manages the workflow lifecycle. - Nodes:
ingestion,extract_evidence,map_criteria,score_item,human_review,persistence. - Routing: Conditional edges loop through the 8 PHQ-8 items before proceeding to review.
- HITL: Configured
MemorySaverto allow human-in-the-loop interrupts at thehuman_reviewstage.
2. State Management (src/helia/agent/state.py)
- Created
ClinicalStatePydantic model. - Strictly types the workflow memory, including:
transcript_text: The input data.scores: A list ofPHQ8ItemScoreobjects (accumulated via reducer).current_item_index: Tracks progress through the 8 items.current_evidence/current_reasoning: Transient fields for the RISEN loop.
3. RISEN Logic (src/helia/agent/nodes/assessment.py)
- Refactored the monolithic evaluation logic into three granular nodes:
- Extract: Finds verbatim quotes for the specific symptom.
- Map: Aligns evidence to the 0-3 scoring criteria.
- Score: Assigns the final value and structured reasoning.
- Prompt Management: Fetches prompts dynamically from the MongoDB
Promptcollection usingPrompt.find_one.
4. Runner & Config (src/helia/agent/runner.py)
- Created a CLI entry point:
python -m helia.agent.runner <run_id>. - Initializes the MongoDB connection via
init_db. - Fetches all available
Transcriptdocuments from the database to run the benchmark. - Injects the specific
RunConfig(Tier 1/2/3) into the graph's runtime configuration.
5. Ingestion (src/helia/ingestion/loader.py)
- Added
ClinicalDataLoaderto abstract transcript fetching. - Loads directly from the
TranscriptBeanie document model in MongoDB.
6. Database Migrations
- Created
migrations/init_risen_prompts.pyto seed the database with the required "RISEN" prompt templates (phq8-extract,phq8-map,phq8-score).
Usage
-
Seed Prompts:
python migrations/init_risen_prompts.py -
Run Agent:
# Run with the default Tier 3 (Cloud) config (defined in config.yaml) python -m helia.agent.runner gemini-flash
Next Steps
- Safety: Implement the
Safety Guardrail(parallel node) as designed inplans/safety-guardrail-architecture.md. - Persistence: Uncomment the DB save logic in
persistence_nodeto saveAssessmentResultdocuments.