Thiago Sandoval
Back to selected work

Engineering case · Rehab IA Pro

Engineering clinical AI agents for assessment and treatment planning.

I architected and implemented agentic workflows that help physiotherapists assess patients, work through differential diagnoses and plan treatment in Rehab IA Pro, a platform in active clinical use.

Context engineering for clinical reasoning

A useful clinical answer depends on connecting the patient’s history, examination findings and supporting evidence. Working with a physiotherapist product owner, I brought consultation history, patient information, questionnaire results and case documents into the clinical AI agent’s context to support assessment and treatment planning. The product owner defines the clinical requirements and protocols.

I implemented tool calling for case-document retrieval and multimodal analysis, so the agent can inspect detailed text and source images when a summary is insufficient. Each request is restricted to the case being discussed and checked against the clinician’s access permissions.

Stateful workflows and human-in-the-loop review

The agent needs to guide an assessment while keeping tentative explanations distinct from findings the physiotherapist has confirmed. I built a stateful assessment workflow that tracks open questions, diagnostic candidates and clinician-confirmed findings, and connected that state to the clinical conversation. That gives the agent the current assessment context for guiding what to examine next.

The workflow also needs a clear rule for questions the agent cannot resolve with sufficient support. I made the assessment engine compare the agent’s proposed answer with a separate confidence check; disagreement or insufficient support sends the question to the physiotherapist. When answers conflict, the clinician’s recorded answer takes precedence.

A reusable engine for clinical protocols

Each clinical condition has its own screening rules and guidance. I separated those definitions from the workflow code so new clinical content can use the same engine. The definitions are supplied by the physiotherapist product owner and distilled from curated scientific research. The engine screens findings, routes diagnostic candidates and selects relevant guidance. The assessment workflow and protocol engine are enabled separately; protocols require clinical review before activation.

Agent evaluation and observability

To assess whether changes to the underlying AI model or its instructions improve the assessment workflow, clinician feedback must be traceable to the configuration that produced each proposal. I built evaluation infrastructure with versioned configurations and feedback linking clinician confirmations and corrections to those proposals. Deterministic A/B assignment keeps each consultation on the same configuration during an experiment.

I also instrumented AI calls for response time, token usage and cost, so configuration comparisons can consider response quality alongside operating cost.