Skip to content

TOADAgents as data. Compiled to types.

Write an AI agent as a tiny, declarative .agent file in a token-oriented syntax derived from TOON. The toac compiler turns it into readable, fully-typed TypeScript that runs on Claude โ€” 30โ€“38% fewer tokens than the JSON it replaces.

TOAD

The whole idea, in one screen โ€‹

You describe what the agent is; the compiler writes how it works.

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;

That .agent file is 101 tokens; the same agent written as JSON is 162 tokens โ€” and at runtime, toolResultFormat: "auto" feeds tabular tool results back to the model as TOON when it's cheaper, saving another 30โ€“40% per result.

Install โ€‹

bash
# the compiler + `toac` CLI
npm i -g toad-compiler

# the runtime your compiled agents import
npm i toad-runtime @anthropic-ai/sdk
bash
toac build researcher.agent   # โ†’ researcher.ts

toad-compiler on npmย  toad-compiler downloadsย  toad-runtime on npmย  GitHub stars

It's open source โ€” come build it โ€‹

TOAD is MIT-licensed and early. Star it, file an issue, or send a PR โ€” the compiler, runtime, language features, and docs are all fair game.

TOAD contributors

Released under the MIT License.