AxAgent Generated TypeScript API reference. typescript api api/reference build/apidocs/Class.AxAgent.md class AxAgent

AxAgent

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L161

Pipeline-based coordinator. Every run walks the same static sequence:

distiller (RLM actor) → executor (RLM actor) ↓ responder (Synthesizer)

The distiller’s final(request, evidence) payload feeds the executor as {executorRequest, distilledContext}. When no contextFields are declared, the distiller still acts as the context-understanding/request-normalization stage over the original inputs.

This is the primary user-facing class. ActorAgentRLM and Synthesizer are exported for callers that need direct per-instance control.

Type Parameters

Type Parameter
IN extends AxGenIn
OUT extends AxGenOut

Implements

Constructors

Constructor

TypeScript
new AxAgent<IN, OUT>(init: Readonly<{
  agentIdentity?: Readonly<AxAgentIdentity>;
  agentModuleNamespace?: string;
  ai?: Readonly<AxAIService>;
  judgeAI?: Readonly<AxAIService>;
  signature:   | string
     | Readonly<AxSignatureConfig>
     | Readonly<AxSignature<IN, OUT>>;
}>, options: Readonly<AxAgentOptions<IN>>): AxAgent<IN, OUT>;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L211

Parameters

ParameterType
initReadonly<{ agentIdentity?: Readonly<AxAgentIdentity>; agentModuleNamespace?: string; ai?: Readonly<AxAIService>; judgeAI?: Readonly<AxAIService>; signature: | string | Readonly<AxSignatureConfig> | Readonly<AxSignature<IN, OUT>>; }>
optionsReadonly<AxAgentOptions<IN>>

Returns

AxAgent<IN, OUT>

Properties

PropertyModifierTypeDescription
distillerreadonlyActorAgentRLM<any, any>RLM actor that normalizes the request and distils context evidence.
distillerAi?readonlyReadonly<AxAIService<unknown, unknown, string>>Per-stage AI service overrides. When set, the corresponding stage uses this AI service instead of the one passed positionally to forward(). forward(ai, ...) is the fallback when the stage-specific override is not defined.
executorreadonlyActorAgentRLM<any, any>RLM actor that runs tools / discovery with the pre-distilled context.
executorAi?readonlyReadonly<AxAIService<unknown, unknown, string>>-
executorExcludeFieldsreadonlySet<string>Field names stripped from executor inputs (from executorOptions.excludeFields).
responderreadonlySynthesizer<OUT>Synthesizer that produces the user’s output signature. Always present.
responderAi?readonlyReadonly<AxAIService<unknown, unknown, string>>-
responderExcludeFieldsreadonlySet<string>Field names stripped from responder inputs (from responderOptions.excludeFields).

Accessors

primaryAgent

Get Signature

TypeScript
get primaryAgent(): ActorAgentRLM<any, any>;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L177

Backward-compat handle used by legacy access patterns: returns the actor stage that “owns” the run-time forward — always the executor in current pipeline shapes. Tests reach in via agent.primaryAgent.actorProgram etc.

Returns

ActorAgentRLM<any, any>

Methods

_forwardForEvaluation()

TypeScript
_forwardForEvaluation<T>(
   parentAi: T, 
   task: Readonly<AxAgentEvalTask<IN>>, 
options?: Readonly<AxProgramForwardOptionsWithModels<T>>): Promise<AxAgentEvalPrediction<OUT>>;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L950

Internal

Used by the optimizer to evaluate a single dataset task end-to-end.

Type Parameters

Type Parameter
T extends Readonly<AxAIService<unknown, unknown, string>>

Parameters

ParameterType
parentAiT
taskReadonly<AxAgentEvalTask<IN>>
options?Readonly<AxProgramForwardOptionsWithModels<T>>

Returns

Promise<AxAgentEvalPrediction<OUT>>


_syncContextMapPrompt()

TypeScript
_syncContextMapPrompt(): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L660

Returns

void


_updateContextMapFromPipelineState()

TypeScript
_updateContextMapFromPipelineState(
   ai: Readonly<AxAIService>, 
   state: Readonly<Record<string, any>>, 
finalOutput?: unknown): Promise<void>;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L668

Parameters

ParameterType
aiReadonly<AxAIService>
stateReadonly<Record<string, any>>
finalOutput?unknown

Returns

Promise<void>


applyOptimization()

TypeScript
applyOptimization(optimizedProgram: any): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L814

Parameters

ParameterType
optimizedProgramany

Returns

void

Implementation of

AxAgentic.applyOptimization


applyOptimizedComponents()

TypeScript
applyOptimizedComponents(updates: Readonly<Record<string, string>>): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L829

Apply a map of componentKey → newValue updates produced by an optimizer. Each program filters keys belonging to itself and dispatches internally. Unknown keys are silently ignored, which lets parents broadcast a single map across the whole subtree.

Parameters

ParameterType
updatesReadonly<Record<string, string>>

Returns

void

Implementation of

AxAgentic.applyOptimizedComponents


forward()

TypeScript
forward<T>(
   ai: T, 
   values: IN, 
options?: Readonly<AxAgentForwardOptions<T>>): Promise<OUT>;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L449

Type Parameters

Type Parameter
T extends Readonly<AxAIService<unknown, unknown, string>>

Parameters

ParameterType
aiT
valuesIN
options?Readonly<AxAgentForwardOptions<T>>

Returns

Promise<OUT>

Implementation of

AxAgentic.forward


getChatLog()

TypeScript
getChatLog(): readonly AxChatLogEntry[];

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L607

Returns

readonly AxChatLogEntry[]

Implementation of

AxAgentic.getChatLog


getContextMap()

TypeScript
getContextMap(): undefined | AxAgentContextMap;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L644

Returns

undefined | AxAgentContextMap


getFunction()

TypeScript
getFunction(): AxFunction;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L465

Returns

AxFunction

Implementation of

AxAgentic.getFunction


getId()

TypeScript
getId(): string;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L485

Returns

string

Implementation of

AxAgentic.getId


getOptimizableComponents()

TypeScript
getOptimizableComponents(): readonly any[];

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L821

Enumerate all string-valued artifacts this program tree exposes for reflective optimization (instructions, signature descriptions, function names/descriptions, agent system prompts, etc.). Composite programs flat-map their children’s components and append their own.

The optimizer never walks the tree — traversal is encapsulated here.

Returns

readonly any[]

Implementation of

AxAgentic.getOptimizableComponents


getSignature()

TypeScript
getSignature(): AxSignature;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L474

Returns

AxSignature

Implementation of

AxAgentic.getSignature


getStagedUsage()

TypeScript
getStagedUsage(): object;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L580

Returns

object

NameType
ctx?AxAgentUsage
taskAxAgentUsage

getState()

TypeScript
getState(): undefined | AxAgentState;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L636

Returns

undefined | AxAgentState


getTraces()

TypeScript
getTraces(): AxProgramTrace<IN, OUT>[];

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L520

Returns

AxProgramTrace<IN, OUT>[]

Implementation of

AxAgentic.getTraces


getUsage()

TypeScript
getUsage(): AxAgentUsage;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L568

Returns

AxAgentUsage

Implementation of

AxAgentic.getUsage


namedProgramInstances()

TypeScript
namedProgramInstances(): AxNamedProgramInstance<IN, OUT>[];

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L510

Returns

AxNamedProgramInstance<IN, OUT>[]

Implementation of

AxAgentic.namedProgramInstances


namedPrograms()

TypeScript
namedPrograms(): object[];

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L498

The distiller is reported under ctx.* and the executor / responder pair under task.* so optimizer demo IDs and template-overrides keep stable stage ownership.

Returns

object[]


optimize()

TypeScript
optimize(dataset: Readonly<AxAgentEvalDataset<IN>>, options?: Readonly<AxAgentOptimizeOptions<_IN, _OUT>>): Promise<AxAgentOptimizeResult<OUT>>;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L837

Parameters

ParameterType
datasetReadonly<AxAgentEvalDataset<IN>>
options?Readonly<AxAgentOptimizeOptions<_IN, _OUT>>

Returns

Promise<AxAgentOptimizeResult<OUT>>


playbook()

TypeScript
playbook(options?: Readonly<AxAgentPlaybookOptions>): AxPlaybook<any, any>;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L865

Build an evolving context AxPlaybook bound to an agent stage (the actor/task stage by default).

Use .update({ example, prediction, feedback }) to refine the playbook from live feedback, or .evolve(dataset, metric) to grow it offline. Offline evolution scores the chosen stage in isolation; for full-pipeline tuning of instructions and demos use optimize instead. Unless apply is false, the rendered playbook is injected into the live stage prompt as it evolves. The evolution engine (ACE) is an implementation detail.

Parameters

ParameterType
options?Readonly<AxAgentPlaybookOptions>

Returns

AxPlaybook<any, any>


resetUsage()

TypeScript
resetUsage(): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L632

Returns

void

Implementation of

AxAgentic.resetUsage


setContextMap()

TypeScript
setContextMap(map?: 
  | string
  | AxAgentContextMapSnapshot
  | AxAgentContextMap): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L648

Parameters

ParameterType
map?| string | AxAgentContextMapSnapshot | AxAgentContextMap

Returns

void


setDemos()

TypeScript
setDemos(demos: readonly (
  | AxAgentDemos<IN, OUT>
  | AxProgramDemos<IN, OUT>)[], options?: object): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L532

Parameters

ParameterType
demosreadonly ( | AxAgentDemos<IN, OUT> | AxProgramDemos<IN, OUT>)[]
options?{ modelConfig?: Record<string, unknown>; }
options.modelConfig?Record<string, unknown>

Returns

void

Implementation of

AxAgentic.setDemos


setId()

TypeScript
setId(id: string): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L489

Parameters

ParameterType
idstring

Returns

void

Implementation of

AxAgentic.setId


setSignature()

TypeScript
setSignature(signature: AxSignatureInput): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L700

Parameters

ParameterType
signatureAxSignatureInput

Returns

void


setState()

TypeScript
setState(state?: AxAgentState): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L640

Parameters

ParameterType
state?AxAgentState

Returns

void


stop()

TypeScript
stop(): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L478

Returns

void


streamingForward()

TypeScript
streamingForward<T>(
   ai: T, 
   values: IN, 
options?: Readonly<AxAgentStreamingForwardOptions<T>>): AxGenStreamingOut<OUT>;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L457

Type Parameters

Type Parameter
T extends Readonly<AxAIService<unknown, unknown, string>>

Parameters

ParameterType
aiT
valuesIN
options?Readonly<AxAgentStreamingForwardOptions<T>>

Returns

AxGenStreamingOut<OUT>

Implementation of

AxAgentic.streamingForward


test()

TypeScript
test(
   code: string, 
   values?: Partial<IN>, 
   options?: Readonly<{
  abortSignal?: AbortSignal;
  ai?: AxAIService<unknown, unknown, string>;
  debug?: boolean;
}>): Promise<AxAgentTestResult>;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/agent/agentInternal/coordinator.ts#L963

Parameters

ParameterType
codestring
values?Partial<IN>
options?Readonly<{ abortSignal?: AbortSignal; ai?: AxAIService<unknown, unknown, string>; debug?: boolean; }>

Returns

Promise<AxAgentTestResult>

Docs