Skip to main content
A clinician speaks during a patient encounter, and an agent fills whichever clinical form is open, such as a triage assessment, a SOAP note, or a PHQ-9 screening. When a form is done, the agent can suggest the next one, and the client swaps forms without losing the conversation. Nothing is saved until the clinician confirms. The recommended setup leaves dictation running for the whole encounter, so the form fills while the clinician talks, as described under Keep dictation running below.
Form-fill flow: the clinician dictates, the client sends the current form state, the agent emits a patch, and the client applies it. The loop repeats with each message. When a form is done, the client may offer the next form. The clinician confirms before anything is saved.Form-fill flow: the clinician dictates, the client sends the current form state, the agent emits a patch, and the client applies it. The loop repeats with each message. When a form is done, the client may offer the next form. The clinician confirms before anything is saved.

The agent fills a form from dictation, patching only what changed with each message. When one form is done, the client can offer the next. The clinician confirms before anything is saved.

This page builds on Build a schema tool, which explains each part of a schema tool. What is new here is a generic schema tool whose vocabulary arrives at runtime: one form_patch tool fills every form, because the paths, collections, and fields it may name come from the form schema the client sends with each message.

Build the form-fill tool

The target: the clinician says “Patient is Daniel, a 34-year-old man, sharp right lower quadrant pain since this morning.” and the agent fills the matching fields of whichever form is open, here a triage form.
1

Define a generic tool with an ops array

form_patch names no form fields. Its schema pins a type discriminator with a const and holds an ops array. Each op is one flat object: only op is required, and op is an enum of six change kinds.
The other op fields, such as path, collection, and field, are all optional on that one object. Which fields each op uses, and which values are valid, is stated in each field’s description, as in Build a schema tool. For example, the path description says that valid paths are defined in the form schema’s scalar_fields.
2

Give each op the fields it needs

Each op targets one kind of form field. set and unset take a path to a single-value field. upsert, remove, and setField take a collection. upsert targets the item’s item.id, while remove and setField take an id. Any of the three can use match instead. string edits a prose field with a mode:
replace edits text in place, so a correction keeps the surrounding sentence intact. The ops table lists the fields of every op.
3

Describe each form as a schema

The vocabulary lives in a form schema, one per form. form_type names the form. scalar_fields hold single values addressed by a dot path, collections hold lists of items described by item_fields, and string_fields hold prose with writing_guidance. This fragment is from the triage form:
The description and enum on each field do the job they do in a schema tool, but they reach the agent as data, not as a connector. A coded field is an object whose description names its parts. In the SOAP form, for example, an allergy’s allergen is described as a SNOMED CT code with conceptId, term, and codeSystem.
4

Send the form in a form_state data part

The client owns the form. With each message, it sends the clinician’s words plus a form_state data part holding the current values. The first message also carries the full schema and a form_catalog listing every form you offer:
When the schema is unchanged, the client leaves schema out and sends "schema_ref": "triage_assessment" with "schema_changed": false, so the agent uses the schema from earlier in the conversation. The client sends the full schema again whenever it changes: after a form swap, when a conditional field appears, or when Text Generation guidance arrives.
5

Finish the form and attach the tool

Next to ops, the patch can carry a status and a suggestion for the next form, picked from the catalog:
The connector uses "transition": "complete", so the run ends each time the agent calls form_patch. Attach the tool with the coding-expert registry connector, which resolves concepts for coded fields. See Medical Coding.

The full body

status and suggestion sit on the patch object next to ops, not inside it. The framework validates each patch against this generic shape, but it cannot know whether a path exists in the open form, so check each op’s target against the current form schema before you apply it.

Point the system prompt at the tool

The tool and the form schema carry most of the rules. The prompt only needs the role, the tools, and the rules specific to filling a form from live dictation:
Three of the rules every flow shares apply here. The agent makes one form_patch call per message, which the complete transition also enforces. It fills only what the clinician said. And it never reports a form as saved, because a patch is a suggestion until the clinician confirms. The rule about requested data does not apply, because this agent never asks the client for data. If patches resend content the form already holds, check that the client sends the updated values with each message before adding prompt rules.
Each time the clinician speaks, the same loop runs:
  1. The client sends the clinician’s words and a form_state data part on the same contextId.
  2. The agent reads form_state, codes any concepts a coded field needs, and calls form_patch with the diff.
  3. The client applies the ops to its local form and shows the result.
The clinician says: “Patient is Daniel, a 34-year-old man, sharp right lower quadrant pain since this morning, nauseated. Temp 38.4, heart rate 104, BP 128 over 82. This is high urgency.” The first form_state carries the triage schema and the catalog, as in step 4. The agent answers:
The client applies the ops in order. set writes at the dot path, creating patient if needed. upsert adds each vital, or replaces an item that has the same id. string with append fills the empty triage_note.The clinician then says: “Disposition is admit. That’s the triage done.” The schema has not changed, so the next form_state carries the updated values with "schema_ref": "triage_assessment" and "schema_changed": false. The agent sends only the new disposition, marks the form complete, and suggests the next form from the catalog:
The client sets values.status to complete, runs any computed fields, and offers the suggestion. Nothing is saved until the clinician confirms.
Leave dictation on for the whole encounter instead of asking the clinician to start and stop it. The form then fills while the clinician talks, and a later correction, such as “actually, temp 38.9”, patches the value set earlier.
  • Stream the clinician’s speech with Corti dictation. Show interim results on screen, but send only final transcript segments to the agent.
  • Send each final segment as its own message, with the current form_state.
  • Send one message at a time, in order. Queue segments that arrive while a run is in progress, and send each with the form state as it is after the previous patch.
When a form completes, the client gathers next-form suggestions from two places: the agent’s suggestion, and the form schema’s own link_rules, which the client evaluates against values. The triage form links to a Glasgow Coma Scale assessment when urgency is critical:
The client merges both sources, drops duplicates and forms already completed, and lets the clinician accept or dismiss each suggestion. A typical chain runs from triage to a SOAP note to a PHQ-9 screening. The link rules add a Glasgow Coma Scale assessment after a critical triage, and an SBAR handoff after a severe Glasgow Coma Scale score.When the clinician accepts, the client swaps the form. It keeps a snapshot of the current form’s values, so the clinician can go back. It loads the target form schema and carries over values whose top-level key the new form also uses, so patient and vitals move from triage to the SOAP note. Then it sends the next form_state with the new schema and schema_changed: true. The client keeps the same contextId, so the agent still has the conversation history and knows the patient.
The client keeps form logic out of the prompt. The agent fills whatever fields the current schema lists, and the client changes that schema.Conditional fields. A form schema’s enable_when rules add a scalar field only when the values meet a condition. In the SOAP form, a high temperature reveals an antipyretics field:
Before each message, the client evaluates the rules and adds the active fields to scalar_fields. When that changes the schema, the client sends the full schema with schema_changed: true. A hidden field keeps its value in values, so the value returns if the field reappears.Computed fields. computed_fields derive values the agent never fills. The client runs them after it applies each patch. In PHQ-9, the agent sets the nine item scores q1 to q9, and the client computes the total and the severity band:
The compute ops are sum, lookup, max_in, min_in, concat, avg, and custom. The max_temperature field that the antipyretics rule reads is itself computed, with max_in over the vitals collection.Text Generation guidance. A string field or collection can name a Text Generation section family, such as "textgen": { "family": "corti-subjective" } on soap.subjective. When a form opens, the client fetches the published section for each family and overlays it on the schema. The section’s contentPrompt becomes the field’s description, and its writingStylePrompt and miscPrompt become the writing_guidance. For a collection, the client converts the section’s outputSchema into item_fields: the fields of the array’s item object. The client then sends the enriched schema with schema_changed: true.Text Generation does not write the note. It supplies the instructions for how to write each section, and the agent still fills the form with form_patch. You can change how a section is written by editing it in the Corti Console, without changing the flow. If no section is found, the field keeps the guidance written in the form schema.

Adapt it

  • Write one form schema per form you offer, with your own field paths, enums, descriptions, and writing guidance. form_patch and the system prompt stay the same.
  • List every form in form_catalog, and write when_to_use and triggers in your clinicians’ terms.
  • Add link_rules for the next-form suggestions you always want, and leave the rest to the agent’s judgment.
  • Add enable_when and computed_fields for conditional fields and scores, so the client, not the prompt, owns that logic.
  • Point string fields and collections at your own Text Generation sections, if you use them.
  • Map the completed form to your EHR’s write API in the client. Nothing is saved until the clinician confirms.