Follow along with the runnable example. This guide walks through the on-demand agent example in
corti-examples — bootstrap your build from it or use it as reference.This guide combines the Commands trigger pattern with the Agentic Framework.The prompts used here are mere examples - be sure to test and refine the prompt to support your specific needs.
Ensure the agent exists
An agent is created once by name and reused. Look it up inclient.agents.list(); create it if missing. See the on-demand agent example in corti-examples for the full ensureAgent implementation. The agent’s behavior lives entirely in its systemPrompt:
Copy-edit system prompt
Trigger it on demand
Expose the action as a voice command (and/or a button). Declare acopy_edit command with phrases like "copy edit", "clean up text", or "polish text" in your dictationConfig.commands, then call runAgent(adapter) when that command fires. See the Commands guide for the declare → event → dispatch pattern.
Run the pass and write back
Send the editor’s current text as a single isolated message (nocontextId — each run stands alone), then replace the editor content via the EditorAdapter with the result. See the on-demand agent example in corti-examples for the full messageSend and write-back implementation.
Next steps
Agentic Framework
What agents are, how to create them, and the message API.
Second-Pass Agent
Run an agent automatically over a finalized transcript.
Example code
The complete, runnable on-demand agent example in
corti-examples.Please contact us for help or questions.