Clinical Evidence Agent
IN PROGRESSDescription
Building a decision-support assistant that helps mental-health professionals ground clinical queries in cited, auditable evidence instead of an LLM's unsourced fluency — architecting the foundation first. A hexagonal core keeps the domain provider-agnostic: it declares an LLMProvider port and imports no vendor SDK, so replacing the model provider is one new adapter instead of a refactor, enforced by an architecture test that parses every module with the Python AST and fails CI if a layer's imports cross its boundary. A two-layer safety contract separates form from policy: Pydantic structured output guarantees the shape of every classification, while a monotonic policy layer escalates to human review on low confidence or clinical urgency and can only add oversight, never remove it. Every call is instrumented against token, latency, and cost baselines with the pricing source and date versioned alongside the report, and provider quota limits are treated as an architectural constraint — a rate-limiting decorator plus bounded retry with backoff — rather than a transient error to swallow. Retrieval over a curated evidence corpus is the next layer, not yet built.
Highlights
- —Architected a provider-agnostic clinical evidence assistant on a hexagonal core: the domain declares an LLMProvider port and imports no vendor SDK, so replacing the model provider with a local model is one new adapter instead of a refactor — enforced by an architecture test that fails CI when a layer crosses its boundary.
- —Designed a two-layer safety contract for mental-health decision support: Pydantic structured output guarantees the shape of every classification, while a separate policy layer escalates to human review on low confidence or clinical urgency — monotonic by design, so the rules can only add human oversight, never remove it.
- —Instrumented token, latency and cost baselines with the pricing source and date versioned alongside the report, and treated provider quota limits as an architectural constraint — rate-limiting decorator plus bounded retry with backoff — rather than a transient error to swallow.
Architecture
Clinical query → domain triage contract (Pydantic QueryTriage: route, priority, confidence, evidence) → monotonic safety policy (escalates to human review on low confidence or high urgency, never removes an existing escalation) → LLMProvider port, with no vendor SDK inside domain/ → a RateLimitedProvider decorator enforcing the provider's per-minute quota → a Gemini adapter with bounded retry and backoff on transient failures. An AST-based architecture test parses every module in each layer and fails CI if an infrastructure import leaks into domain or application. Token, latency, and cost are measured on every call and versioned into a baseline report alongside the pricing source and date.