Skip to content

Examples

Each example below is the real .agent source and the exact toac output. Every one has an "open in playground" link — edit it there and watch it recompile live.

researcher — tools + structured output

agent
agent: researcher
model: claude-opus-4-7
description: Research a topic and return a sourced summary.
inputs[1]{name,type}:
  topic,string
tools[2]: web_search,fetch_page
prompt: |
  You are a research analyst. Research: {inputs.topic}
  Use web_search to find sources, then fetch_page to read them.
  Return a cited summary.
outputs[2]{name,type}:
  summary,string
  sources,string[]
ts
// Generated by toac from researcher.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";
import { web_search, fetch_page } from "./researcher.tools";

export interface ResearcherInput {
  topic: string;
}

export interface ResearcherOutput {
  summary: string;
  sources: string[];
}

const inputSchema = z.object({
  topic: z.string(),
});

const outputSchema = z.object({
  summary: z.string(),
  sources: z.array(z.string()),
});

export const researcher: Agent<ResearcherInput, ResearcherOutput> = createAgent({
  name: "researcher",
  model: "claude-opus-4-7",
  description: "Research a topic and return a sourced summary.",
  tools: { web_search, fetch_page },
  inputSchema,
  outputSchema,
  prompt: (inputs: ResearcherInput) =>
    `You are a research analyst. Research: ${inputs.topic}
Use web_search to find sources, then fetch_page to read them.
Return a cited summary.`,
});

export default researcher;

Open in playground →

summarizer — typed array output

agent
agent: summarizer
model: claude-opus-4-7
description: Summarize text into key bullet points.
inputs[1]{name,type}:
  text,string
prompt: |
  Summarize the following into 3-5 concise bullet points:
  {inputs.text}
outputs[1]{name,type}:
  bullets,string[]
ts
// Generated by toac from summarizer.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface SummarizerInput {
  text: string;
}

export interface SummarizerOutput {
  bullets: string[];
}

const inputSchema = z.object({
  text: z.string(),
});

const outputSchema = z.object({
  bullets: z.array(z.string()),
});

export const summarizer: Agent<SummarizerInput, SummarizerOutput> = createAgent({
  name: "summarizer",
  model: "claude-opus-4-7",
  description: "Summarize text into key bullet points.",
  inputSchema,
  outputSchema,
  prompt: (inputs: SummarizerInput) =>
    `Summarize the following into 3-5 concise bullet points:
${inputs.text}`,
});

export default summarizer;

Open in playground →

digest — {#each} loop with index

agent
agent: digest
model: claude-opus-4-7
description: Turn a list of notes into a short summary.
inputs[1]{name,type}:
  notes,string[]
prompt: |
  Summarize these notes into a short paragraph:
  {#each inputs.notes as note, i}
  {i}. {note}
  {/each}
outputs[1]{name,type}:
  summary,string
ts
// Generated by toac from digest.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface DigestInput {
  notes: string[];
}

export interface DigestOutput {
  summary: string;
}

const inputSchema = z.object({
  notes: z.array(z.string()),
});

const outputSchema = z.object({
  summary: z.string(),
});

export const digest: Agent<DigestInput, DigestOutput> = createAgent({
  name: "digest",
  model: "claude-opus-4-7",
  description: "Turn a list of notes into a short summary.",
  inputSchema,
  outputSchema,
  prompt: (inputs: DigestInput) =>
    `Summarize these notes into a short paragraph:
${inputs.notes.map((note, i) => `${i}. ${note}
`).join("")}`,
});

export default digest;

Open in playground →

report — {#each} + {#if} conditional

agent
agent: report
model: claude-opus-4-7
description: Write a report from findings, optionally detailed.
inputs[2]{name,type}:
  findings,string[]
  detailed,boolean
prompt: |
  Write a report from these findings:
  {#each inputs.findings as f}
  - {f}
  {/each}
  {#if inputs.detailed}
  Include a thorough analysis section.
  {:else}
  Keep it to a single paragraph.
  {/if}
outputs[1]{name,type}:
  report,string
ts
// Generated by toac from report.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface ReportInput {
  findings: string[];
  detailed: boolean;
}

export interface ReportOutput {
  report: string;
}

const inputSchema = z.object({
  findings: z.array(z.string()),
  detailed: z.boolean(),
});

const outputSchema = z.object({
  report: z.string(),
});

export const report: Agent<ReportInput, ReportOutput> = createAgent({
  name: "report",
  model: "claude-opus-4-7",
  description: "Write a report from findings, optionally detailed.",
  inputSchema,
  outputSchema,
  prompt: (inputs: ReportInput) =>
    `Write a report from these findings:
${inputs.findings.map((f) => `- ${f}
`).join("")}${inputs.detailed ? `Include a thorough analysis section.
` : `Keep it to a single paragraph.
`}`,
});

export default report;

Open in playground →

brief — object types, destructuring, kitchen sink

agent
agent: brief
model: claude-opus-4-7
description: Summarize sources for an audience, optionally in detail.
inputs[3]{name,type}:
  sources,"{title:string;url:string}[]"
  detailed,boolean
  audience,string
prompt: |
  Write a brief for {inputs.audience}.
  {#each inputs.sources as {title, url}, i}
  {i}. {title} — {url}
  {:else}
  No sources provided.
  {/each}
  {#if inputs.detailed}
  Include a thorough analysis section.
  {:else}
  Keep it to a single paragraph.
  {/if}
outputs[1]{name,type}:
  brief,string
ts
// Generated by toac from brief.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface BriefInput {
  sources: { title: string; url: string }[];
  detailed: boolean;
  audience: string;
}

export interface BriefOutput {
  brief: string;
}

const inputSchema = z.object({
  sources: z.array(z.object({ title: z.string(), url: z.string() })),
  detailed: z.boolean(),
  audience: z.string(),
});

const outputSchema = z.object({
  brief: z.string(),
});

export const brief: Agent<BriefInput, BriefOutput> = createAgent({
  name: "brief",
  model: "claude-opus-4-7",
  description: "Summarize sources for an audience, optionally in detail.",
  inputSchema,
  outputSchema,
  prompt: (inputs: BriefInput) =>
    `Write a brief for ${inputs.audience}.
${inputs.sources.length > 0 ? inputs.sources.map(({ title, url }, i) => `${i}. ${title} — ${url}
`).join("") : `No sources provided.
`}${inputs.detailed ? `Include a thorough analysis section.
` : `Keep it to a single paragraph.
`}`,
});

export default brief;

Open in playground →

classifier — enum output (a closed set of labels)

agent
agent: classifier
model: claude-opus-4-7
description: Classify a support message by intent.
inputs[1]{name,type}:
  message,string
prompt: |
  Classify this customer message by intent:
  {inputs.message}
outputs[2]{name,type}:
  intent,billing|technical|sales|other
  confidence,number
ts
// Generated by toac from classifier.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface ClassifierInput {
  message: string;
}

export interface ClassifierOutput {
  intent: "billing" | "technical" | "sales" | "other";
  confidence: number;
}

const inputSchema = z.object({
  message: z.string(),
});

const outputSchema = z.object({
  intent: z.enum(["billing", "technical", "sales", "other"]),
  confidence: z.number(),
});

export const classifier: Agent<ClassifierInput, ClassifierOutput> = createAgent({
  name: "classifier",
  model: "claude-opus-4-7",
  description: "Classify a support message by intent.",
  inputSchema,
  outputSchema,
  prompt: (inputs: ClassifierInput) =>
    `Classify this customer message by intent:
${inputs.message}`,
});

export default classifier;

Open in playground →

translator — minimal interpolation

agent
agent: translator
model: claude-opus-4-7
description: Translate text into a target language.
inputs[2]{name,type}:
  text,string
  target,string
prompt: |
  Translate the following into {inputs.target}. Return only the translation.
  {inputs.text}
outputs[1]{name,type}:
  translation,string
ts
// Generated by toac from translator.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface TranslatorInput {
  text: string;
  target: string;
}

export interface TranslatorOutput {
  translation: string;
}

const inputSchema = z.object({
  text: z.string(),
  target: z.string(),
});

const outputSchema = z.object({
  translation: z.string(),
});

export const translator: Agent<TranslatorInput, TranslatorOutput> = createAgent({
  name: "translator",
  model: "claude-opus-4-7",
  description: "Translate text into a target language.",
  inputSchema,
  outputSchema,
  prompt: (inputs: TranslatorInput) =>
    `Translate the following into ${inputs.target}. Return only the translation.
${inputs.text}`,
});

export default translator;

Open in playground →

sql-generator — schema in, query + explanation out

agent
agent: sql_generator
model: claude-opus-4-7
description: Turn a question into SQL against a given schema.
inputs[2]{name,type}:
  question,string
  schema,string
prompt: |
  Given this database schema:
  {inputs.schema}

  Write a single SQL query that answers: {inputs.question}
outputs[2]{name,type}:
  sql,string
  explanation,string
ts
// Generated by toac from sql_generator.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface SqlGeneratorInput {
  question: string;
  schema: string;
}

export interface SqlGeneratorOutput {
  sql: string;
  explanation: string;
}

const inputSchema = z.object({
  question: z.string(),
  schema: z.string(),
});

const outputSchema = z.object({
  sql: z.string(),
  explanation: z.string(),
});

export const sql_generator: Agent<SqlGeneratorInput, SqlGeneratorOutput> = createAgent({
  name: "sql_generator",
  model: "claude-opus-4-7",
  description: "Turn a question into SQL against a given schema.",
  inputSchema,
  outputSchema,
  prompt: (inputs: SqlGeneratorInput) =>
    `Given this database schema:
${inputs.schema}

Write a single SQL query that answers: ${inputs.question}`,
});

export default sql_generator;

Open in playground →

code-reviewer — array of objects with an enum field

agent
agent: code_reviewer
model: claude-opus-4-7
description: Review a diff and return structured findings.
inputs[2]{name,type}:
  diff,string
  language,string
prompt: |
  Review this {inputs.language} diff for bugs, style, and clarity:
  {inputs.diff}

  Return one finding per issue.
outputs[1]{name,type}:
  findings,"{line:number;severity:low|medium|high;message:string}[]"
ts
// Generated by toac from code_reviewer.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface CodeReviewerInput {
  diff: string;
  language: string;
}

export interface CodeReviewerOutput {
  findings: { line: number; severity: "low" | "medium" | "high"; message: string }[];
}

const inputSchema = z.object({
  diff: z.string(),
  language: z.string(),
});

const outputSchema = z.object({
  findings: z.array(z.object({ line: z.number(), severity: z.enum(["low", "medium", "high"]), message: z.string() })),
});

export const code_reviewer: Agent<CodeReviewerInput, CodeReviewerOutput> = createAgent({
  name: "code_reviewer",
  model: "claude-opus-4-7",
  description: "Review a diff and return structured findings.",
  inputSchema,
  outputSchema,
  prompt: (inputs: CodeReviewerInput) =>
    `Review this ${inputs.language} diff for bugs, style, and clarity:
${inputs.diff}

Return one finding per issue.`,
});

export default code_reviewer;

Open in playground →

email-writer — enum input (tone)

agent
agent: email_writer
model: claude-opus-4-7
description: Draft an email in a chosen tone.
inputs[3]{name,type}:
  recipient,string
  topic,string
  tone,formal|casual|friendly
prompt: |
  Write an email to {inputs.recipient} about {inputs.topic}.
  Use a {inputs.tone} tone.
outputs[2]{name,type}:
  subject,string
  body,string
ts
// Generated by toac from email_writer.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface EmailWriterInput {
  recipient: string;
  topic: string;
  tone: "formal" | "casual" | "friendly";
}

export interface EmailWriterOutput {
  subject: string;
  body: string;
}

const inputSchema = z.object({
  recipient: z.string(),
  topic: z.string(),
  tone: z.enum(["formal", "casual", "friendly"]),
});

const outputSchema = z.object({
  subject: z.string(),
  body: z.string(),
});

export const email_writer: Agent<EmailWriterInput, EmailWriterOutput> = createAgent({
  name: "email_writer",
  model: "claude-opus-4-7",
  description: "Draft an email in a chosen tone.",
  inputSchema,
  outputSchema,
  prompt: (inputs: EmailWriterInput) =>
    `Write an email to ${inputs.recipient} about ${inputs.topic}.
Use a ${inputs.tone} tone.`,
});

export default email_writer;

Open in playground →

support-agent — multiple tools + escalation

agent
agent: support_agent
model: claude-opus-4-7
description: Answer a customer question from the knowledge base, escalating if needed.
inputs[1]{name,type}:
  question,string
tools[2]: search_kb,create_ticket
prompt: |
  Answer the customer's question: {inputs.question}
  Search the knowledge base first with search_kb. If you can't resolve it,
  open a ticket with create_ticket and tell the customer.
outputs[2]{name,type}:
  answer,string
  escalated,boolean
ts
// Generated by toac from support_agent.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";
import { search_kb, create_ticket } from "./support_agent.tools";

export interface SupportAgentInput {
  question: string;
}

export interface SupportAgentOutput {
  answer: string;
  escalated: boolean;
}

const inputSchema = z.object({
  question: z.string(),
});

const outputSchema = z.object({
  answer: z.string(),
  escalated: z.boolean(),
});

export const support_agent: Agent<SupportAgentInput, SupportAgentOutput> = createAgent({
  name: "support_agent",
  model: "claude-opus-4-7",
  description: "Answer a customer question from the knowledge base, escalating if needed.",
  tools: { search_kb, create_ticket },
  inputSchema,
  outputSchema,
  prompt: (inputs: SupportAgentInput) =>
    `Answer the customer's question: ${inputs.question}
Search the knowledge base first with search_kb. If you can't resolve it,
open a ticket with create_ticket and tell the customer.`,
});

export default support_agent;

Open in playground →

contact-extractor — structured extraction

agent
agent: contact_extractor
model: claude-opus-4-7
description: Pull contact fields out of unstructured text.
inputs[1]{name,type}:
  text,string
prompt: |
  Extract the contact details from this text. Use an empty string for any
  field that is not present.
  {inputs.text}
outputs[4]{name,type}:
  name,string
  email,string
  phone,string
  company,string
ts
// Generated by toac from contact_extractor.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface ContactExtractorInput {
  text: string;
}

export interface ContactExtractorOutput {
  name: string;
  email: string;
  phone: string;
  company: string;
}

const inputSchema = z.object({
  text: z.string(),
});

const outputSchema = z.object({
  name: z.string(),
  email: z.string(),
  phone: z.string(),
  company: z.string(),
});

export const contact_extractor: Agent<ContactExtractorInput, ContactExtractorOutput> = createAgent({
  name: "contact_extractor",
  model: "claude-opus-4-7",
  description: "Pull contact fields out of unstructured text.",
  inputSchema,
  outputSchema,
  prompt: (inputs: ContactExtractorInput) =>
    `Extract the contact details from this text. Use an empty string for any
field that is not present.
${inputs.text}`,
});

export default contact_extractor;

Open in playground →

meeting-notes — several array outputs at once

agent
agent: meeting_notes
model: claude-opus-4-7
description: Turn a transcript into notes, actions, and decisions.
inputs[1]{name,type}:
  transcript,string
prompt: |
  From this meeting transcript, produce a short summary, the action items,
  and the decisions made:
  {inputs.transcript}
outputs[3]{name,type}:
  summary,string
  action_items,string[]
  decisions,string[]
ts
// Generated by toac from meeting_notes.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface MeetingNotesInput {
  transcript: string;
}

export interface MeetingNotesOutput {
  summary: string;
  action_items: string[];
  decisions: string[];
}

const inputSchema = z.object({
  transcript: z.string(),
});

const outputSchema = z.object({
  summary: z.string(),
  action_items: z.array(z.string()),
  decisions: z.array(z.string()),
});

export const meeting_notes: Agent<MeetingNotesInput, MeetingNotesOutput> = createAgent({
  name: "meeting_notes",
  model: "claude-opus-4-7",
  description: "Turn a transcript into notes, actions, and decisions.",
  inputSchema,
  outputSchema,
  prompt: (inputs: MeetingNotesInput) =>
    `From this meeting transcript, produce a short summary, the action items,
and the decisions made:
${inputs.transcript}`,
});

export default meeting_notes;

Open in playground →

product-namer — number input + array output

agent
agent: product_namer
model: claude-opus-4-7
description: Brainstorm product names in a given style.
inputs[3]{name,type}:
  description,string
  count,number
  style,playful|professional|techy
prompt: |
  Suggest {inputs.count} {inputs.style} names for this product:
  {inputs.description}
outputs[1]{name,type}:
  names,string[]
ts
// Generated by toac from product_namer.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface ProductNamerInput {
  description: string;
  count: number;
  style: "playful" | "professional" | "techy";
}

export interface ProductNamerOutput {
  names: string[];
}

const inputSchema = z.object({
  description: z.string(),
  count: z.number(),
  style: z.enum(["playful", "professional", "techy"]),
});

const outputSchema = z.object({
  names: z.array(z.string()),
});

export const product_namer: Agent<ProductNamerInput, ProductNamerOutput> = createAgent({
  name: "product_namer",
  model: "claude-opus-4-7",
  description: "Brainstorm product names in a given style.",
  inputSchema,
  outputSchema,
  prompt: (inputs: ProductNamerInput) =>
    `Suggest ${inputs.count} ${inputs.style} names for this product:
${inputs.description}`,
});

export default product_namer;

Open in playground →

changelog-writer — {#each} over commit messages

agent
agent: changelog_writer
model: claude-opus-4-7
description: Turn raw commit messages into a readable changelog.
inputs[2]{name,type}:
  version,string
  commits,string[]
prompt: |
  Write a changelog for {inputs.version}, grouping these commits by type
  (features, fixes, docs):
  {#each inputs.commits as c}
  - {c}
  {/each}
outputs[1]{name,type}:
  changelog,string
ts
// Generated by toac from changelog_writer.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface ChangelogWriterInput {
  version: string;
  commits: string[];
}

export interface ChangelogWriterOutput {
  changelog: string;
}

const inputSchema = z.object({
  version: z.string(),
  commits: z.array(z.string()),
});

const outputSchema = z.object({
  changelog: z.string(),
});

export const changelog_writer: Agent<ChangelogWriterInput, ChangelogWriterOutput> = createAgent({
  name: "changelog_writer",
  model: "claude-opus-4-7",
  description: "Turn raw commit messages into a readable changelog.",
  inputSchema,
  outputSchema,
  prompt: (inputs: ChangelogWriterInput) =>
    `Write a changelog for ${inputs.version}, grouping these commits by type
(features, fixes, docs):
${inputs.commits.map((c) => `- ${c}
`).join("")}`,
});

export default changelog_writer;

Open in playground →

faq-bot — object-array input + {#each}/{#if}

agent
agent: faq_bot
model: claude-opus-4-7
description: Answer a question from a provided FAQ, optionally strict.
inputs[3]{name,type}:
  question,string
  faqs,"{q:string;a:string}[]"
  strict,boolean
prompt: |
  Answer the question using this FAQ:
  {#each inputs.faqs as {q, a}}
  Q: {q}
  A: {a}
  {:else}
  (no FAQ entries provided)
  {/each}
  Question: {inputs.question}
  {#if inputs.strict}
  If none of the entries apply, reply that you don't know.
  {:else}
  If none apply, answer from general knowledge and say so.
  {/if}
outputs[2]{name,type}:
  answer,string
  matched,boolean
ts
// Generated by toac from faq_bot.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface FaqBotInput {
  question: string;
  faqs: { q: string; a: string }[];
  strict: boolean;
}

export interface FaqBotOutput {
  answer: string;
  matched: boolean;
}

const inputSchema = z.object({
  question: z.string(),
  faqs: z.array(z.object({ q: z.string(), a: z.string() })),
  strict: z.boolean(),
});

const outputSchema = z.object({
  answer: z.string(),
  matched: z.boolean(),
});

export const faq_bot: Agent<FaqBotInput, FaqBotOutput> = createAgent({
  name: "faq_bot",
  model: "claude-opus-4-7",
  description: "Answer a question from a provided FAQ, optionally strict.",
  inputSchema,
  outputSchema,
  prompt: (inputs: FaqBotInput) =>
    `Answer the question using this FAQ:
${inputs.faqs.length > 0 ? inputs.faqs.map(({ q, a }) => `Q: ${q}
A: ${a}
`).join("") : `(no FAQ entries provided)
`}Question: ${inputs.question}
${inputs.strict ? `If none of the entries apply, reply that you don't know.
` : `If none apply, answer from general knowledge and say so.
`}`,
});

export default faq_bot;

Open in playground →

persona-bot — a system: prompt block

agent
agent: persona_bot
model: claude-opus-4-7
description: Answer as a specific persona.
system: |
  You are a terse senior engineer. Prefer concrete examples over theory and
  never use more words than necessary.
inputs[1]{name,type}:
  question,string
prompt: |
  {inputs.question}
outputs[1]{name,type}:
  answer,string
ts
// Generated by toac from persona_bot.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";

export interface PersonaBotInput {
  question: string;
}

export interface PersonaBotOutput {
  answer: string;
}

const inputSchema = z.object({
  question: z.string(),
});

const outputSchema = z.object({
  answer: z.string(),
});

export const persona_bot: Agent<PersonaBotInput, PersonaBotOutput> = createAgent({
  name: "persona_bot",
  model: "claude-opus-4-7",
  description: "Answer as a specific persona.",
  inputSchema,
  outputSchema,
  system: (inputs: PersonaBotInput) =>
    `You are a terse senior engineer. Prefer concrete examples over theory and
never use more words than necessary.`,
  prompt: (inputs: PersonaBotInput) =>
    `${inputs.question}`,
});

export default persona_bot;

Open in playground →

research-director — uses: composition (multi-agent)

agent
agent: research_director
model: claude-opus-4-7
description: Research a topic, then condense it for an executive.
inputs[1]{name,type}:
  topic,string
uses[2]: researcher,summarizer
prompt: |
  Research {inputs.topic} with the researcher sub-agent, then run the result
  through the summarizer to produce an executive-ready brief.
outputs[1]{name,type}:
  brief,string
ts
// Generated by toac from research_director.agent — do not edit.
import { createAgent, type Agent } from "toad-runtime";
import { z } from "zod";
import { researcher } from "./researcher";
import { summarizer } from "./summarizer";

export interface ResearchDirectorInput {
  topic: string;
}

export interface ResearchDirectorOutput {
  brief: string;
}

const inputSchema = z.object({
  topic: z.string(),
});

const outputSchema = z.object({
  brief: z.string(),
});

export const research_director: Agent<ResearchDirectorInput, ResearchDirectorOutput> = createAgent({
  name: "research_director",
  model: "claude-opus-4-7",
  description: "Research a topic, then condense it for an executive.",
  tools: { researcher: researcher.asTool(), summarizer: summarizer.asTool() },
  inputSchema,
  outputSchema,
  prompt: (inputs: ResearchDirectorInput) =>
    `Research ${inputs.topic} with the researcher sub-agent, then run the result
through the summarizer to produce an executive-ready brief.`,
});

export default research_director;

Open in playground →


There's also a complete, type-checked project in the repo: examples/researcher.agent source, generated .ts, tool implementations, and a live integration test.

Released under the MIT License.