Documentation

Build LLM-powered agents
with production-ready TypeScript

DSPy for TypeScript. Working with LLMs is complex—they don't always do what you want. DSPy makes it easier to build amazing things with LLMs. Just define your inputs and outputs (signature) and an efficient prompt is auto-generated and used. Connect together various signatures to build complex systems and workflows using LLMs.

15+ LLM Providers
End-to-end Streaming
Auto Prompt Tuning

AxACE

Defined in: https://github.com/ax-llm/ax/blob/0aa4aa2ceed1ba61106711baed6ce962cf2eb604/src/ax/dsp/optimizers/ace.ts#L139

AxACE implements the Agentic Context Engineering loop (Generator → Reflector → Curator). The implementation mirrors the paper’s architecture while integrating with the Ax optimizer ergonomics (unified optimized program artifacts, metrics, and checkpointing).

Extends

Constructors

Constructor

new AxACE(args: Readonly<AxOptimizerArgs>, options?: Readonly<AxACEOptions>): AxACE;

Defined in: https://github.com/ax-llm/ax/blob/0aa4aa2ceed1ba61106711baed6ce962cf2eb604/src/ax/dsp/optimizers/ace.ts#L151

Parameters

ParameterType
argsReadonly<AxOptimizerArgs>
options?Readonly<AxACEOptions>

Returns

AxACE

Overrides

AxBaseOptimizer.constructor

Methods

applyOnlineUpdate()

applyOnlineUpdate(args: Readonly<{
  example: AxExample;
  feedback?: string;
  prediction: unknown;
}>): Promise<undefined | AxACECuratorOutput>;

Defined in: https://github.com/ax-llm/ax/blob/0aa4aa2ceed1ba61106711baed6ce962cf2eb604/src/ax/dsp/optimizers/ace.ts#L454

Apply ACE updates after each online inference. Mirrors the online adaptation flow described in the paper; can be called by user-land code between queries.

Parameters

ParameterType
argsReadonly<{ example: AxExample; feedback?: string; prediction: unknown; }>

Returns

Promise<undefined | AxACECuratorOutput>


compile()

compile<IN, OUT>(
   program: Readonly<AxGen<IN, OUT>>, 
   examples: readonly AxTypedExample<IN>[], 
   metricFn: AxMetricFn, 
options?: AxACECompileOptions): Promise<AxACEResult<OUT>>;

Defined in: https://github.com/ax-llm/ax/blob/0aa4aa2ceed1ba61106711baed6ce962cf2eb604/src/ax/dsp/optimizers/ace.ts#L195

Abstract method that must be implemented by concrete optimizers

Type Parameters

Type Parameter
IN
OUT extends AxGenOut

Parameters

ParameterType
programReadonly<AxGen<IN, OUT>>
examplesreadonly AxTypedExample<IN>[]
metricFnAxMetricFn
options?AxACECompileOptions

Returns

Promise<AxACEResult<OUT>>

Overrides

AxBaseOptimizer.compile


compilePareto()

compilePareto<IN, OUT>(
   program: Readonly<AxGen<IN, OUT>>, 
   examples: readonly AxTypedExample<IN>[], 
   metricFn: AxMultiMetricFn, 
options?: AxCompileOptions): Promise<AxParetoResult<OUT>>;

Defined in: https://github.com/ax-llm/ax/blob/0aa4aa2ceed1ba61106711baed6ce962cf2eb604/src/ax/dsp/optimizer.ts#L1561

Multi-objective optimization using Pareto frontier Default implementation that leverages the single-objective compile method

Type Parameters

Type Parameter
IN
OUT extends AxGenOut

Parameters

ParameterTypeDescription
programReadonly<AxGen<IN, OUT>>The program to optimize
examplesreadonly AxTypedExample<IN>[]Training examples
metricFnAxMultiMetricFnMulti-objective metric function that returns multiple scores
options?AxCompileOptionsOptional configuration options

Returns

Promise<AxParetoResult<OUT>>

Pareto optimization result with frontier of non-dominated solutions

Inherited from

AxBaseOptimizer.compilePareto


compileStream()

compileStream<IN, OUT>(
   program: Readonly<AxGen<IN, OUT>>, 
   examples: readonly AxTypedExample<IN>[], 
   metricFn: AxMetricFn, 
options?: AxCompileOptions): AsyncIterableIterator<AxOptimizationProgress>;

Defined in: https://github.com/ax-llm/ax/blob/0aa4aa2ceed1ba61106711baed6ce962cf2eb604/src/ax/dsp/optimizer.ts#L1448

Optimize a program with real-time streaming updates

Type Parameters

Type Parameter
IN
OUT extends AxGenOut

Parameters

ParameterTypeDescription
programReadonly<AxGen<IN, OUT>>The program to optimize
examplesreadonly AxTypedExample<IN>[]Training examples
metricFnAxMetricFnEvaluation metric function
options?AxCompileOptionsOptional configuration options

Returns

AsyncIterableIterator<AxOptimizationProgress>

Async iterator yielding optimization progress

Inherited from

AxBaseOptimizer.compileStream


configureAuto()

configureAuto(level: "light" | "medium" | "heavy"): void;

Defined in: https://github.com/ax-llm/ax/blob/0aa4aa2ceed1ba61106711baed6ce962cf2eb604/src/ax/dsp/optimizers/ace.ts#L178

Parameters

ParameterType
level"light" | "medium" | "heavy"

Returns

void


getStats()

getStats(): AxOptimizationStats;

Defined in: https://github.com/ax-llm/ax/blob/0aa4aa2ceed1ba61106711baed6ce962cf2eb604/src/ax/dsp/optimizer.ts#L2494

Get current optimization statistics

Returns

AxOptimizationStats

Current optimization statistics

Inherited from

AxBaseOptimizer.getStats


reset()

reset(): void;

Defined in: https://github.com/ax-llm/ax/blob/0aa4aa2ceed1ba61106711baed6ce962cf2eb604/src/ax/dsp/optimizers/ace.ts#L168

Reset optimizer state for reuse with different programs

Returns

void

Overrides

AxBaseOptimizer.reset