Agent Intermediate Representation

AIR

A formal IR for agent code, prompts, tools, and protocols.

AIR models LLM-based agent systems before deployment. It lowers framework code and natural-language instructions into one conservative representation so static passes can check dataflow, authority, topology, and policy intent.

AIR workflow and prompt lowering map

What AIR Represents

Workflow and prompts are first-class IR facts.

AIR is not an agent runtime. It is a compiler target for analysis: frontends recover the real agent workflow, collect the full prompt assembly, run shared prompt autoformalization, and merge everything into the same checkable module.

Agent workflow

Agents, regions, blocks, topology, tools, state, memory, model calls, and protocol edges.

Prompt workflow

Prompt sources, templates, sections, slots, semantic roles, comments, docstrings, and manifests.

Formalized prompt AIR

Autoformalized persona, obligations, prohibitions, capabilities, and grounded prompt evidence.

Pipeline

Every frontend follows one boundary.

  1. 1

    Parse source

    Known frameworks use direct parsers. Unknown systems use generic discovery.

  2. 2

    Assemble prompt corpus

    Frontends gather natural-language prompt, skill, tool, and manifest evidence.

  3. 3

    Autoformalize prompts

    The shared layer turns prompt evidence into formalized prompt AIR.

  4. 4

    Merge and check

    Workflow AIR, prompt assembly AIR, and formalized prompt AIR become one module.

Use AIR

Compile, format, then check.

Start with the frontend that matches your source. The generated `.air` file is meant to be read, formatted, diffed, and checked in CI.

Quickstart
cargo check --workspace
cargo run -q -p air-driver --bin airc -- agent --framework langgraph ./app > app.air
cargo run -q -p air-driver --bin air-fmt -- --write app.air
cargo run -q -p air-driver --bin air-check -- app.air

Documentation

The docs are a separate reader, backed by JSON.

The manual lives in `docs/air/*.md`, is generated into `/api/docs/*.json`, and is displayed by the docs page. Internal design notes stay out of the public docs API.