Skip to main content
One way to connect a Corti agent to an electronic health record (EHR) is through schema tools: tools you define with a JSON Schema that say exactly what the agent can request or propose. The agent does not read from or write to the EHR itself. Your application, the client, carries out each request against the EHR and decides what gets saved. In the recipes here, nothing is saved until the clinician confirms. Extract and write to EHR builds a schema tool step by step. The other recipes add more schema syntax, each with a task you can build. Recipes are patterns to adapt, not fixed integrations. Field names and codes follow FHIR R4, and where your EHR uses different names, the client can map between them. The input to any recipe may be typed or dictated: dictation is an input modality, not a property of a particular flow.

How a recipe works

A recipe pairs schema tools with a system prompt, and your application carries out what the agent asks for.
  • Schema tools define what the agent can emit. Each is your own tool defined by a JSON Schema (type: object, additionalProperties: false), attached to the agent as a schema-type connector. Its transition field is the agent’s exit state: input_required when the agent yields to wait on the client or clinician, or complete when it is done. The framework enforces both the schema and the transition. The connector type is defined once in Connectors, and each recipe page builds the concrete connector bodies you attach.
  • The system prompt shapes the flow: when the agent uses each tool, and how. The agent classifies the request, chooses the tool, fills the schema, and yields. Most of it lives in the system prompt, and each tool’s description carries the rules for that tool.
  • Your application is the client. It owns state and persistence, and it runs the apply-step: fetching the EHR data the agent asks for, applying records, and placing orders. Each recipe page shows the apply-step for its flow. Nothing is saved until the clinician confirms.
The division of labor is the same across all recipes.
The seam in flow recipes: the clinician turns to the agent, the agent emits a proposal, the client applies it, and nothing is saved until the clinician confirms.The seam in flow recipes: the clinician turns to the agent, the agent emits a proposal, the client applies it, and nothing is saved until the clinician confirms.

The seam: the agent proposes, the client persists, and nothing is saved until the clinician confirms (the dotted green edge)

The agent owns the proposal: classifying the clinician’s intent, choosing the tool and filling the schema, coding concepts through registry connectors, grounding every answer in returned data, suggesting the next action or form. The client owns the apply-step: fetching EHR data, applying records, driving the order catalog and forms, and persistence, only after the clinician confirms.

Build or adapt a recipe

To adapt a recipe, change the schema, its descriptions, and the client’s apply-step to match the EHR you integrate with. The steps use Extract and write to EHR as the running example.
1

Scope the task

Name what starts the task, what the agent does, the result you expect, and the tools it needs. If one of the recipes under What you can build matches, start from it. For extract: a clinician states a clinical fact, the agent turns it into a coded record suggestion, and the tools are one schema tool per clinical family, starting with extract_allergy, plus the coding-expert registry connector.
2

Write the system prompt

The schema tools define what the agent can emit. The system prompt defines how it behaves as the clinician asks for things: which tool fits which request, when to yield, and when to answer. The systemPrompt is yours: it depends on what your system exposes, and it moves as your flows settle. Each recipe page carries a minimal prompt that routes requests to its tools, so build the agent for one task first, then add nuance once you see where your agent actually goes wrong. For extract, the prompt routes each stated fact to its family’s tool. For more on the systemPrompt field, see Create and configure an agent.Some rules hold in every flow, because they are what the agent is for. Add them to each recipe’s minimal prompt, either together in one block or next to the routing and flow rules they govern. Either way, state them as plainly as any other instruction:
  • “One tool call per turn. Never two.”
  • “After requested data arrives, do not request it again in that same turn.”
  • “Say only what a tool returned. Never fill a gap.”
  • “Nothing is saved until the clinician confirms. Never report a record as saved.”
The last rule could keep the agent from describing a suggestion as a saved record, for example by saying “Documented” after it proposes an extraction.
3

Start from the schema

Copy the connector body from the recipe that matches your task, listed under What you can build. For extract, that is the extract_allergy body. Build a schema tool explains each field.
4

Map the vocabulary to your EHR

Swap enums for your system’s codes. Use your categories, note types, observation types, and code systems. additionalProperties: false means what is not in the schema cannot be emitted, so the schema is the complete menu of what the agent may produce.
5

Tune the description

The tool’s rules, when to use it, the confirmation seam, and one-action-per-call live in prose in the description, not in code. The LLM reads that string. Edit it to match how your clinicians speak and which domains your EHR exposes.
6

Attach it to your agent

Include the object inline in the agent’s connectors array at creation time, as shown in Create and configure an agent, or POST it to the connector sub-resource, as shown in Manage connectors. Attach any coding or knowledge registry connectors the recipe needs in the same array: the extract recipe uses coding-expert for coded concepts (allergy, diagnosis, observation, …), documented in Medical Coding.
7

Own the apply-step on the client

The agent emits. The client persists. For extract, the client completes the confirmed record and sends it to your write API. For retrieve, it resolves the request against your EHR’s read API and returns the records as a new message on the same contextId, carrying a data part (see Send a message to an agent). A task in input_required is not finished: the new message resumes it, as described in Task lifecycle. For order, it resolves the catalog search and places the confirmed order through your order system. For form-fill, it merges the patch into your local form state. Nothing is saved until the clinician confirms.

What you can build

Each schema-tool recipe builds a task and adds schema syntax that the recipes before it did not need. The recipes are not the only schema tools you can build: any tool your agent needs is defined the same way.

Based on FHIR R4

The schema tools use resource names, field names, and codes from FHIR R4, a widely used standard for health records. The agent fills the clinical content. Your application adds the rest of the record, such as the patient reference, before it saves anything.

Combine agents

Generic multi-agent composition: an orchestrator agent coordinates several sub-agents through structured output contracts, and the composition's output is pending clinician confirmation.Generic multi-agent composition: an orchestrator agent coordinates several sub-agents through structured output contracts, and the composition's output is pending clinician confirmation.

The composition: an orchestrator agent coordinates sub-agents through structured output contracts, and the output is pending clinician confirmation (the dotted green edge)

When one task needs several scoped skills, an orchestrator agent can stitch several agents into one composition. The orchestrator owns the task decomposition and the traceability between sub-agents, and each sub-agent owns exactly one scoped clinical task. The agents pass structured output contracts to each other rather than filling a single connector body, and each sub-agent may bring its own registry connectors. The orchestrator yields the composition’s output as a proposal, so the same seam applies: nothing is saved until the clinician confirms. Some tasks that suit a composition:
  • Differential diagnosis: one agent takes the history, one proposes hypotheses, and one weighs them against the literature with the pubmed-expert registry connector. The clinician confirms the working diagnosis.
  • Triage: one agent rates urgency, one codes the presenting complaint with coding-expert, and the clinician approves before the case is routed.
  • Medication review: one agent gathers the current medications from the EHR, one checks interactions and dosing with drugbank-expert or posos-expert, and one drafts recommendations for the clinician.
  • Pre-visit intake: one agent interviews the patient with interviewing-expert, one fills the intake form with the form-fill tool, and one codes the reason for the visit.
To wire agents together in code, see Multi-agent composition.

Registry connectors

Recipes compose with registry connectors: pre-built integrations for coding, knowledge, and intake. The extract recipe attaches the coding-expert registry connector alongside its schema connector to resolve concepts to codes, documented in Medical Coding. Browse the full catalog at Registry connectors.

What changes, what doesn’t

Changes per system:
  • The schema’s enums and field vocabulary.
  • The description prose.
  • The client’s apply-step, and the read and write API calls behind each data part.
  • The set of available domains and note types.
Stays the same:
  • The connector body shape.
  • The shape of the agent’s systemPrompt: the rules every flow shares and the per-flow minimums stay, the wording is yours.
  • The additionalProperties: false contract.
  • The transitions.
  • The seam: the agent proposes, and nothing is saved until the clinician confirms.
  • The connector model.