Skip to main content
Follow along with the runnable example. This guide walks through the second-pass agent example in corti-examples — bootstrap your build from it or use it as reference.
Where the on-demand agent runs when the user asks, a second-pass agent runs automatically as the final step of a transcription pipeline. Generate an offline transcript with /transcripts, then feed the finalized result to an Agentic Framework agent — for example to produce a concise clinical summary from a diarized conversation.
This guide chains two earlier ones: the File Transcription pipeline and the agent lifecycle from On-Demand Agent (create-by-name, isolated messageSend, prompt-driven behavior).The prompts used here are mere examples - be sure to test and refine the prompt to support your specific needs.

Chain the second pass

Run the pipeline to completion, then hand the finalized transcript to the agent as a second stage. Keep them as distinct steps so the transcript is the source of truth and the agent run is an augmentation on top of it.
JavaScript

Prepare the agent input

A /transcripts result is a set of segments, not a flat string. Flatten it for the agent — and prefix each segment with its speaker or channel label so the agent can reason about who said what.
JavaScript
The second-pass behavior lives in the agent’s systemPrompt:
Second-pass system prompt

Keep the transcript on agent failure

The transcript and the agent pass are independent results. If the second pass errors — a 403, a timeout, an empty response — preserve the finalized transcript and surface the agent error separately. Never discard a good transcript because the augmentation failed.
Treat the second pass as an optional stage layered on the transcript pipeline: the transcript always renders, and the agent output appears when (and if) it succeeds. Store the prompt per API client so it can be tuned without a code change.

Next steps

File Transcription

The /transcripts pipeline this second pass runs on top of.

On-Demand Agent

The agent lifecycle and message API, triggered manually instead.

Example code

The complete, runnable second-pass agent example in corti-examples.
Please contact us for help or questions.