Praxis Async

Engineering design document

04B / 08
Part 04BMaster architecture · Decide what matters now

Filter broadly. Reason selectively. Explain every priority.

Given an updated longitudinal patient state, Praxis determines whether meaningful work exists, which bounded specialists should reason, how urgency compares across the panel and what evidence supports the result.

NoAction

No meaningful clinical work is required; the reason and evidence are still recorded.

DecisionCandidate

A versioned recommendation with urgency, evidence, confidence, safety requirements and expiration.

End-to-end control flow

Services control the work; agents perform bounded reasoning

01

Trigger & freeze

Start from a schedule, clinician request or meaningful PatientStateChanged event; freeze the patient and panel snapshot.

02

Gate & pre-rank

Apply safety overrides, eligibility rules and cheap longitudinal scoring before any agent runs.

03

Build context

Assemble a versioned, task-specific ContextPacket from clinical, evidence, workflow, preference and guideline memory.

04

Route specialists

Match clear clinical changes deterministically; use a small model only when unstructured intent is ambiguous.

05

Reason selectively

Run one to three relevant specialists in parallel against the same patient-state version.

06

Reconcile & ground

Merge compatible assessments, preserve conflicts and verify every clinical claim against current evidence.

07

Validate & rank

Apply deterministic safety and freshness policies, then produce an explainable DecisionCandidate or NoAction.

08

Hand off durable work

Temporal carries the validated candidate into approval and coordination.

Panel funnel · illustrative

Do not reason over all 1,200 patients at request time

1,200

deterministically scored

30

strong candidates

8

need fresh reasoning

Fresh DecisionCandidates are reused. Agents run only for high-ranking patients whose reasoning is missing, stale or conflicting.

Runtime agent count

No meaningful change0 agents
Single-condition case1 specialist + validator
Multi-condition case2–3 specialists + reconciler + validator
Unresolved complexityfrontier reconciliation + human

Context Builder

Agents start stateless—with the minimum trusted memory they need

01

Clinical memory

PostgreSQL

Current snapshot, personal baselines, longitudinal trends, active conditions and open care gaps.

02

Evidence memory

pgvector + text search

Notes, reports, messages and source-linked document chunks.

03

Workflow memory

PostgreSQL + Temporal

Previous recommendations, approvals, rejections, completed actions and current execution state.

04

Preference memory

PostgreSQL

Explicit clinician communication, routing and workflow preferences—separate from clinical truth.

05

Knowledge memory

Versioned knowledge store

Approved clinical guidelines and organization policies with effective dates and versions.

Versioned ContextPacket

A frozen, agent-specific view—not the entire chart

context_idpatient_idworkflow_idtriggeras_ofstate_versionrelevant_changelongitudinal_windowevidence_citationsguideline_versionsprior_outcomespreferencesmissing_or_conflicting_dataallowed_toolsrisk_leveltoken_budgetexpires_at

Agents fetch additional facts through typed tools. They never directly modify clinical, evidence, workflow or preference memory.

Agent runtime

Ten registered roles; two to five usually execute

01

Clinical Coordinator

Optional

Scopes complex or ambiguous multi-condition reasoning.

02

Diabetes & Metabolic

Specialist

Reviews metabolic trends, care gaps and related complications.

03

Cardiovascular

Specialist

Reviews cardiovascular changes and relevant longitudinal risk.

04

Kidney

Specialist

Reviews renal trends, gaps and cross-condition implications.

05

Medication Safety

Specialist

Reviews medication changes, monitoring and interactions.

06

Preventive Care

Specialist

Reviews screening, vaccination and preventive gaps.

07

Reconciler

Shared

Combines compatible assessments and preserves unresolved conflicts.

08

Grounding Reviewer

Shared

Verifies claims, citations, freshness and guideline support.

09

Inbox Drafting

Workflow

Converts a validated decision into a reviewable response draft.

10

Practice Improvement

Workflow

Finds practice-level patterns from governed aggregate evidence.

Agent Directory

Approved, versioned manifests

agent_id + version
supported workflows
condition + event triggers
required context
input + output schemas
allowed tool IDs
model policy
risk class
token + timeout budget
prompt version
evaluation suite
lifecycle status
Draft
Offline eval
Shadow
Canary
Active
Disabled

Tool Gateway

Typed access—not arbitrary database queries

Patient state

Read

snapshot · timeline · labs · medications · care gaps · prior outcomes

Evidence

Read

document search · message thread · source chunk · citation resolver

Knowledge

Read

guideline search · approved section · organization policy

Calculations

Compute

approved measure · personal baseline · trend · interaction check

Preparation

Prepare

message draft · task draft · order request · EHR note draft

Execution

Approval only

send message · create task · submit order · write note

Controlled delegation

Need more data?

Call a scoped read tool.

Need another specialty?

Return a SpecialistRequest.

Router decides

Check relevance, duplication, risk and budget before Temporal starts it.

No direct agent spawning · no recursive delegation · maximum depth one · maximum three specialists

Model routing + prioritization

Complexity chooses the model; risk chooses the safeguards

Tier 0

No model

Rules, calculations, safety gates and ranking

Deduplicate an event, compare to baseline and score the panel.

0 tokens

Tier 1

Small model

Classification and extraction

Extract symptom, timing and likely specialty from an ambiguous message.

≤ 2k in · 150 out

Tier 2

Mid-tier model

Normal specialist reasoning, drafting and grounding

Assess one condition using relevant trends, evidence and guidelines.

≤ 8–12k in · 1.2k out

Tier 3

Frontier model

Complex multi-condition reconciliation

Resolve conflicting specialists across a long, contradictory timeline.

≤ 24k in · 1.5k out

Explainable priority · initial hypothesis

0–100 factor score

Potential clinical severity30%
Change from personal baseline25%
Time sensitivity20%
Unresolved work15%
Actionability10%

Safety overrides run first. Confidence and freshness remain separate; uncertainty never silently lowers a serious case.

Freshness + concurrency

Never publish against stale state

Version dependencies

Candidate records input state, trigger events, guideline and agent versions.

Dependency invalidation

Only related labs, medications, messages or completed actions invalidate it.

Signal active workflow

Temporal groups related events; critical events bypass batching.

Compare before activation

A changed relevant state version rejects publication and reruns affected steps.

DecisionCandidate contract

priority tier + score breakdown
what changed
why it matters now
recommended next step
evidence + citations
confidence + missing data
required approval
state, agent, model + guideline versions
created_at + expires_at

Worked escalation trace

One event moves through every control layer

Illustrative scenario: a new laboratory result arrives and the patient reports dizziness after a recent medication change.

01Ingestion

Two new signals

A new lab result arrives and the patient reports dizziness after a medication change.

02Tier 0

Deterministic gate

Verify identity, update longitudinal state, compare to baseline and apply critical-event policy.

03Tier 1

Classify ambiguity

Extract symptom, timing and the likely kidney + medication-safety specialties from the message.

04Context

Build shared context

Load renal trend, medication timeline, prior actions, approved guidance and exact citations.

05Tier 2

Reason in parallel

Kidney and Medication Safety Agents independently produce typed, cited assessments.

06Tier 3

Escalate conflict

If assessments materially disagree, frontier reconciliation resolves what it can and preserves uncertainty.

07Human gate

Validate and approve

Ground every claim, apply safety policy and present evidence, conflicts and missing data to the clinician.

08

Clinician chooses

Approve, edit, reject, request more information or escalate. No action executes before the required gate.

Reliability + evaluation

Fail visibly, replay safely and test every boundary

Failure behavior

Transient tool failure

Retry with backoff and the same idempotency key.

Invalid model output

One schema repair; then approved same-tier fallback.

Required specialist fails

Stop completion and route to human review.

Context becomes stale

Reject activation and rerun only the affected steps.

Grounding fails

One revision cycle; then human escalation.

Worker crashes

Temporal resumes from recorded workflow state.

Evaluation layers

Deterministic unit tests

routing · scores · freshness · policies · idempotency

Tool contract tests

schemas · scope · permissions · timeouts · citations

Agent evaluation suites

correctness · abstention · grounding · calibration · cost

Multi-agent tests

agreement · conflicts · partial failure · unsupported synthesis

Workflow replay tests

crashes · duplicate events · cancellation · late approval

Deployment gates

offline → replay → shadow → clinician review → canary

Versioned assumptions

Values are hypotheses until evaluations calibrate them

Priority-score weights and tier boundaries
Critical-event and approval policies
Panel funnel sizes and maximum three specialists
Candidate expiration and invalidation rules
Model assignment, token budgets and escalation thresholds
Latency, cost and confidence targets

Decision principle

Tools fetch facts. Agents reason within boundaries. The router delegates. Independent reviewers validate. Humans authorize consequential action.