Skip to content
Healthcare SoftwareEngineering

Agentic AI

Healthcare AI Agents With Scoped Tools and Approval Gates

An agent that can call tools can also call the wrong tool, with the wrong patient, at the wrong time. We engineer healthcare AI agents so that every action is permissioned, logged, reversible where possible, and approved by a person when the stakes call for it.

Healthcare AI agents: overview

The word agent covers a lot of ground. In practice, a healthcare AI agent is a language model that plans a sequence of steps and invokes tools, such as a FHIR search, a scheduling API, a payer eligibility check, or a task creation endpoint, to complete a goal. That makes it more useful than a chat assistant and considerably riskier, because its mistakes are actions rather than words.

Our approach starts with the tool layer, not the model. Each tool gets a narrow contract, an explicit permission scope tied to the user or service on whose behalf the agent acts, input validation, and a classification as read-only, reversible write, or irreversible write. Irreversible actions, such as sending a message to a patient or submitting a claim, require a human approval step. Read-only actions still get logged, because an agent browsing records it did not need is itself an access event.

We also design for the cases where agents get stuck: loops that repeat the same search, plans that drift off-task, tools that return errors, and ambiguous patient matches. Every agent run has step limits, time limits, and cost limits, and a clean handoff to a human work queue with the full trace attached. A trace a person can read is what makes an agent supportable in production.

Engineering challenges in healthcare AI agents

  • 01Over-broad tool permissions

    Giving an agent a service account with read access to every patient is the fastest way to build a demo and the fastest way to create an access-control problem. Agents should inherit the requesting user's scopes or a narrowly defined service scope.

  • 02Patient identity ambiguity

    Two patients with the same name and birth year in a search result can lead an agent to act on the wrong chart. We require explicit identifier confirmation before any write and stop the run when a match is ambiguous.

  • 03Runaway loops and costs

    An agent retrying a failing eligibility call can make dozens of model calls in a minute. Without step, token, and wall-clock budgets, one bad input can generate a large bill and a flood of downstream requests.

  • 04Injection through tool results

    Text returned from a document or message, such as a fax that says to ignore previous instructions, can redirect an agent. Tool outputs must be treated as data and kept out of the instruction channel.

  • 05Traces nobody can read

    When an agent does something unexpected, support staff need to see each step, the reasoning summary, the tool call, and the result. Raw model logs are not enough for incident review.

Technical capabilities

What our healthcare AI agents work covers

  • Tool contract design

    We define each tool with typed inputs and outputs, a risk classification, rate limits, and idempotency keys for writes. Tools are small and specific, which makes agent behavior easier to test and audit.

  • Scoped authorization

    Agents act with SMART on FHIR scopes or OAuth tokens bound to the requesting user or a defined service identity, never a blanket administrator credential. Scope checks happen in the tool layer, not in the prompt.

  • Human approval gates

    Irreversible or patient-affecting actions pause the run and present a proposed action with context to a person who approves, edits, or rejects it. Approvals are recorded with identity and timestamp.

  • Run budgets and circuit breakers

    Each run carries maximum steps, tokens, tool calls, and elapsed time. Repeated identical tool calls trip a loop detector, and error rates above a threshold open a circuit breaker for that tool.

  • Step-level audit trail

    Every plan step, tool invocation, parameters, result summary, and approval is written to an append-only audit store with the agent, prompt, and model versions, so any run can be reconstructed.

  • Deterministic fallbacks

    Where a fixed workflow handles most cases, we keep it as the primary path and use the agent only for the residual cases. This keeps behavior predictable for the bulk of the volume.

  • Scenario-based agent testing

    We build simulated environments with fictional patients and mocked tools to test complete agent runs, including error injection, ambiguous matches, and adversarial content in tool results.

Software architecture

Reference architecture for healthcare AI agents

A production healthcare agent separates planning from execution. The model proposes; a policy layer decides whether the proposed action is allowed, needs approval, or must stop.

  1. Entry
    • User or event trigger
    • Identity and scopes
    • Run budget assignment
  2. Planning
    • Pinned LLM
    • Versioned system prompt
    • Step memory
  3. Policy and guardrails
    • Tool allowlist
    • Risk classifier
    • Approval router
    • Loop detector
  4. Tools
    • FHIR read tools
    • Scheduling API
    • Task creation
    • Eligibility check
  5. Oversight
    • Approval queue
    • Run trace viewer
    • Audit store
    • Human handoff queue
Illustrative layering; actual architecture is decided per engagement and documented in decision records.

Technology stack for healthcare AI agents

Agent runtime
Python or TypeScript orchestrationFunction callingState machines for fixed paths
Authorization
SMART on FHIR scopesOAuth 2.0Policy engine (e.g. OPA)
Healthcare APIs
FHIR R4X12 270/271 eligibilityScheduling APIs
Reliability
Idempotency keysCircuit breakersDurable workflow engine
Observability
OpenTelemetry tracesAppend-only audit logRun replay tooling

Security & compliance

Security and compliance considerations for healthcare AI agents

What regulations require

  • The HIPAA Security Rule requires access controls (45 CFR 164.312(a)) and audit controls (45 CFR 164.312(b)); an agent that reads or writes ePHI is a system actor whose access must be controlled and recorded like any other.
  • The HIPAA Privacy Rule's minimum necessary standard (45 CFR 164.502(b)) applies to uses and disclosures of PHI for operations and payment purposes, which argues for agents scoped to the records a task requires.
  • If an agent's output is intended to inform clinical decisions, FDA's September 2022 CDS guidance and the section 520(o) criteria are relevant to whether the function is a device; agents that act autonomously on clinical matters are unlikely to fit the non-device CDS criteria, which assume a professional can independently review the basis for a recommendation.

Recommended engineering practices

  • Classify every tool as read-only, reversible write, or irreversible write, and require human approval for the last category.
  • Keep tool results out of the system prompt and mark them clearly as untrusted data in the context.
  • Bind agent credentials to the requesting user's scopes and expire them with the run.
  • Use idempotency keys on every write so a retried step cannot create duplicate orders, tasks, or messages.
  • Map agent risks to the NIST AI RMF Manage function, including documented decommissioning procedures.

Regulatory summaries are educational, not legal advice. HIPAA compliance is an organizational program; software can support safeguards but cannot by itself make an organization compliant. Systems that handle PHI need their own risk analysis, vendor evaluation, and Business Associate Agreements before deployment.

Integration capabilities

Integrations we engineer for healthcare AI agents

  • FHIR R4 read and write APIs
  • SMART on FHIR authorization servers
  • Scheduling and slot APIs
  • X12 270/271 eligibility services
  • Task and work-queue systems
  • Secure messaging and in-basket
  • Durable workflow engines

Engineering methodology

How we approach healthcare AI agents

  1. 1

    Map the job

    Document the human workflow the agent assists, each decision point, and which steps are read, reversible write, or irreversible.

  2. 2

    Design tools first

    Specify narrow tool contracts, scopes, and risk classes before writing prompts, and build mocked versions for testing.

  3. 3

    Build the policy layer

    Implement allowlists, approval routing, budgets, loop detection, and the human handoff path.

  4. 4

    Simulate

    Run hundreds of scripted scenarios against mocked tools with fictional patients, including failures and adversarial inputs, and review traces.

  5. 5

    Supervised rollout

    Start with every action requiring approval, then relax approval only for action types whose approval history supports it.

Business use cases

Where healthcare AI agents delivers value

  • Referral intake coordination

    An agent reads an incoming referral, checks eligibility, finds candidate appointment slots, and proposes a booking for a scheduler to confirm.

  • Prior authorization status chasing

    An agent checks payer portals or APIs for pending authorizations and creates tasks for staff when documentation is requested.

  • Care gap outreach preparation

    An agent assembles the list of open gaps for a patient panel and drafts outreach tasks, leaving contact decisions to care coordinators.

  • Chart preparation for visits

    An agent gathers outside records, recent results, and open orders into a pre-visit summary for clinician review.

Technical comparison

Agent versus fixed workflow automation
AspectFixed workflowLLM agent
PredictabilityHigh; same input, same pathVariable; plan can differ per run
Handles unusual inputsPoorly; falls to exception queueBetter, within tool limits
TestingPath coverageScenario simulation and trace review
AuditStep logStep log plus model reasoning summary
Cost per runLow and fixedVariable; needs budgets
Best fitHigh-volume, well-defined tasksLong-tail cases needing judgment and lookup

Typical deliverables

What a healthcare AI agents engagement produces

  • Workflow map with action risk classification
  • Tool contracts and mocked tool implementations
  • Policy layer with approval routing and budgets
  • Scenario test suite with fictional patient data
  • Run trace viewer and audit store
  • Human handoff and escalation design
  • Operational runbook including agent disablement

Agent production readiness

  • Every tool has a risk class and a scope check
  • Irreversible actions require human approval
  • Step, token, and time budgets are enforced
  • Ambiguous patient matches stop the run
  • Tool results are treated as untrusted data
  • Full run traces are viewable by support staff
  • A single switch disables the agent and routes work to people

Cost and timeline factors

What shapes healthcare AI agents cost and timeline

  • Number and complexity of tools the agent uses
  • Proportion of actions that need approval workflows
  • Availability of sandbox or test environments for target systems
  • Scenario test suite breadth
  • Model choice and expected run volume
  • Integration effort with existing work queues

Typical timeline

An agent with a handful of read tools and one approval-gated write can reach a supervised pilot in a couple of months. Agents spanning multiple systems with write access usually take two or more quarters, largely because sandbox access and scenario testing take time.

Read the cost guide

Healthcare AI agents FAQs

What is a healthcare AI agent?

A healthcare AI agent is a language-model-driven system that plans steps and calls tools, such as FHIR queries, scheduling APIs, or task systems, to complete a goal like preparing a referral. Unlike a chatbot, it takes actions. That makes permission scoping, approval gates for consequential actions, and step-level audit trails essential parts of the engineering.

Should an AI agent be allowed to write to the EHR?

Only through narrow, validated tools with the requesting user's permissions, idempotency protection, and, for anything clinically or financially consequential, a human approval step. Many teams start with read-only agents that propose actions and add approved writes once approval history shows which action types are reliable.

How do you stop an agent from looping or running up costs?

Each run has hard limits on steps, tokens, tool calls, and elapsed time. A loop detector catches repeated identical tool calls, and circuit breakers stop calls to a failing tool. When a limit is hit, the run stops and passes to a human queue with its trace, rather than retrying indefinitely.

When is a fixed workflow better than an agent?

When the task is high-volume and the steps are well defined, a deterministic workflow is cheaper, faster, and easier to validate. Agents earn their place in the long tail: cases where inputs vary and the next step depends on what a lookup returns. A common design uses a fixed workflow for most cases and an agent for exceptions.

Discuss your healthcare engineering project

Tell us about the system, the integrations it depends on, and the constraints you are working within. A senior engineer will review it and reply with questions, not a sales script.