AI engineerCase studyClearPath agent

An agent that knows when to escalate.

Prior authorization is slow paperwork with real consequences. ClearPath is a LangGraph agent that resolves the clear cases on its own and sends every denial and every uncertain case to a human with its reasoning attached. It runs on Google Cloud Run and is also exposed as an MCP server.

Role
Solo: design, build, evaluation, deploy
Stack
Python · LangGraph · GPT-4o · RAG · Langfuse · FastAPI · Docker · Google Cloud Run · MCP Python SDK
When
Deployed to Cloud Run with MCP in October 2026
Proof
Live app · GitHub
55%Auto-resolved on 20 synthetic cases
100%Denials routed to a human
$0.005Average cost per decision
4MCP tools for any MCP client
01 / The problem

Automate the easy part, never the risky one.

Most prior-authorization requests are routine: the documentation either meets the written clinical criteria or it doesn't. Reviewers spend their time on the routine ones. But a wrong automated denial harms a patient, and a decision nobody can explain can't be defended later.

So the design goal wasn't "maximum automation". It was: resolve what is clearly safe, escalate everything else, and leave an audit trail for every decision.

02 / How it works

Propose, criticize, then route.

Requestcase data RetrieveRAG: criteria Proposerdraft decision Criticchallenges it Routein Python Auto-resolvedconfident approvals Human review queueevery denial · low confidence Approve / Denyaudited decision send back: re-runs with the reviewer's notes (max 3)
The LangGraph pipeline; the routing decision is code, not the model
  • Retrieve: RAG over the written clinical criteria for the requested procedure, so every decision is grounded in a cited rule.
  • Proposer and critic: one step drafts a decision with a rationale; a second step challenges it against the criteria before anything is final.
  • Route in Python: only confident approvals are auto-resolved. Every denial and every low-confidence case goes to the human review queue. The model can't change that rule.
  • Human in the loop: a reviewer can approve, deny or send back; a send-back re-runs the graph with the reviewer's notes (capped at 3 rounds).
  • Traced: every node is traced in Langfuse (inputs, outputs, cost, latency) and shown as an in-app audit trail.

Shipping it

  • Containerized with Docker and deployed on Google Cloud Run with scale-to-zero, an Artifact Registry cleanup policy and a budget alert.
  • Exposed as an MCP server (official MCP Python SDK, stateless streamable HTTP, DNS-rebinding protection) with four tools: list sample cases, search criteria, review a case, and read the eval metrics.
  • Later hardened with a full OWASP security review: see the security case study.
03 / Results

Measured, not estimated.

20 synthetic cases, GPT-4oResult
Auto-resolved11 of 20 (55%)
Escalated to a human9 of 20 (45%): every denial
Average cost per decisionabout $0.005
Average decision timeabout 3.6 seconds
The trade-off

The critic step costs most of the per-decision spend, and it would be cheaper to skip it. I kept it because a second, adversarial pass is what makes the auto-approvals trustworthy, and at half a cent per decision the cost is small next to a reviewer's time. The data is synthetic; a real deployment would need a clinical evaluation set.

04 / What I'd do next

Where it goes from here.

  • Evaluate on a larger, clinician-labelled case set and report precision on auto-approvals specifically.
  • Calibrate the confidence threshold against reviewer outcomes instead of a fixed cut-off.
  • Track reviewer send-back reasons to find which criteria the agent misreads most.
More case studies
Get in touch

Need an AI system that holds up in production?

Tell me what you're building and where it breaks. I'll tell you straight whether I can help.

Cairo, Egypt — US, UK & Gulf time zones LinkedIn GitHub