Ax (AxACE optimizer)
Type: full-code · Vendor: ax-llm · Language: TypeScript · License: Apache-2.0 · Status: active · Status in practice: emerging · First released: 2023-12-01
Ax is a DSPy port that compiles typed declarative signatures into LLM calls and optimizes the resulting prompts and demonstrations against an evaluation metric.
Description. Ax is a framework for building LLM applications around declarative signatures rather than hand-written prompts. A signature declares the typed inputs and outputs of a step, and Ax turns it into the prompt, the output parser, the validators, and the retry loop, returning typed data. Ax includes optimizers, among them AxACE, which mirrors the Agentic Context Engineering paper's Generator-Reflector-Curator loop and a Genetic-Pareto optimizer that tunes prompts and demonstrations against evals. It is released under Apache 2.0.
Agent loop shape. A developer declares a signature stating what goes in and what comes out. Ax compiles the signature into a prompt, schema, parser, validators, and retry loop, runs it against the model, and returns typed output. Given example input/output pairs and a metric, an optimizer such as GEPA or AxACE searches for better prompts and demonstrations; AxACE additionally maintains a structured bullet playbook updated through add/update/remove deltas at inference time.
Primary use cases
- building LLM pipelines from typed signatures
- automatic prompt and few-shot optimization
- agentic context engineering with an evolving playbook
- type-safe structured outputs from LLMs
Key concepts
- Signature → dspy-signatures (docs) — A one-line declaration of a step's typed inputs and outputs that Ax compiles into the prompt, output parser, validators, and retry loop, so the developer states what goes in and out rather than writing a prompt.
- GEPA optimizer → evaluator-optimizer (docs) — The Genetic-Pareto optimizer that searches over prompts, demonstrations, flows, and agents against an evaluation metric to improve a signature-driven program without manual prompt edits.
- AxACE → agentic-context-engineering-playbook (docs) — An optimizer that mirrors the Agentic Context Engineering Generator-Reflector-Curator loop, representing context as structured bullets and applying incremental add/update/remove deltas into a serialized playbook updatable at inference time.
- AxAgent → agent-as-tool-embedding (docs) — A three-stage pipeline that turns a signature into a long-running, tool-using actor whose memory, skills, MCP tools, and child agents are exposed as typed capabilities behind the signature contract.
- ai() provider handle → multi-model-routing (docs) — The single constructor that binds a program to a model provider — OpenAI, Claude, Gemini, a gateway, or a local OpenAI-compatible endpoint — leaving signatures, tools, traces, and outputs unchanged when the provider is swapped.
Patterns this full-code implements —
- ★DSPy Signatures
Ax is a port of DSPy in which behaviour is specified as a declarative typed signature rather than a prompt; Ax compiles the signature into the prompt, parser, validators, and retry loop and returns t…
- ★★Structured Output
A signature declares typed outputs and Ax validates the generated fields against them, accepting a string DSL, a fluent builder, or a Standard Schema validator such as Zod, so downstream code receive…
- ·Agentic Context Engineering Playbook
AxACE mirrors the ACE Generator-Reflector-Curator loop, holds context as a structured bullet playbook, and applies add/update/remove deltas (offline compile and online inference-time updates) to resi…
- ★★Tool Use
Ax exposes typed host functions and MCP servers as callable capabilities and runs a ReAct-style tool loop, letting a signature-driven program invoke functions with typed arguments and typed returns d…
- ★Agent-as-Tool Embedding
AxAgent turns a signature into a long-running tool-using actor whose child agents are exposed as typed capabilities behind the same signature contract, so a parent agent calls a sub-agent the same wa…
- ★★Multi-Model Routing
A single ai() call selects OpenAI, Claude, Gemini, a gateway, or a local OpenAI-compatible endpoint while signatures, tools, traces, and outputs stay unchanged, so the same program runs against diffe…
- ★★Streaming Typed Events
Streaming is the default: Ax parses signature fields as they arrive, runs streaming assertions, and can fail and cancel an in-flight stream before the model finishes, returning typed structured resul…
Neighbourhood
Click any neighbour to follow the lineage. Scroll to zoom, drag to pan.