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/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L189

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/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L245

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
autoUpgradeResolvedreadonlyAxResolvedAutoUpgradeResolved auto-upgrade config; also read by the responder-input helpers.
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/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L205

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/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L1225

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/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L741

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/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L749

Parameters

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

Returns

Promise<void>


_updatePlaybookFromPipelineState()

TypeScript
_updatePlaybookFromPipelineState(state: Readonly<Record<string, any>>): Promise<
  | undefined
| AxAgentPlaybookUpdateResult>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L1107

Internal

Run-end failure learning for the attached playbook (see AxAgentPlaybookConfig.learn): merge the stages’ deterministic failure reports, gate on volume and signature novelty, then feed one bounded playbook update whose curated rules land in the failures_to_avoid section. Non-fatal by construction — playbook upkeep must never break the completed user-facing run.

Public for the pipeline flow node and tests.

Parameters

ParameterType
stateReadonly<Record<string, any>>

Returns

Promise< | undefined | AxAgentPlaybookUpdateResult>


addActorInstruction()

TypeScript
addActorInstruction(addendum: string): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L949

Append a standing instruction addendum to the executor actor’s prompt. A separate additive channel from executorOptions.description and the playbook injection, so the three never clobber each other. Process-local — not serialized into AxAgentState.

Parameters

ParameterType
addendumstring

Returns

void


applyOptimization()

TypeScript
applyOptimization(optimizedProgram: any): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L903

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/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L918

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 & object, 
options?: Readonly<AxAgentForwardOptions<T>>): Promise<OUT>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L512

Run the agent once.

Type Parameters

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

Parameters

ParameterTypeDescription
aiT-
valuesIN & objectSignature inputs plus an optional memories array. Forward memories are visible from the first actor turn, merge with recalled entries by ID, and reset before the next call.
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/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L688

Returns

readonly AxChatLogEntry[]

Implementation of

AxAgentic.getChatLog


getContextMap()

TypeScript
getContextMap(): undefined | AxAgentContextMap;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L725

Returns

undefined | AxAgentContextMap


getFunction()

TypeScript
getFunction(): AxFunction;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L546

Returns

AxFunction

Implementation of

AxAgentic.getFunction


getId()

TypeScript
getId(): string;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L566

Returns

string

Implementation of

AxAgentic.getId


getOptimizableComponents()

TypeScript
getOptimizableComponents(): readonly any[];

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L910

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


getPlaybook()

TypeScript
getPlaybook(): 
  | undefined
| AxAgentPlaybook<any, any>;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L986

The agent’s playbook handle, or undefined if none has been created.

Returns

| undefined | AxAgentPlaybook<any, any>


getSignature()

TypeScript
getSignature(): AxSignature;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L555

Returns

AxSignature

Implementation of

AxAgentic.getSignature


getStagedUsage()

TypeScript
getStagedUsage(): object;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L661

Returns

object

NameType
ctx?AxAgentUsage
taskAxAgentUsage

getState()

TypeScript
getState(): undefined | AxAgentState;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L717

Returns

undefined | AxAgentState


getTraces()

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

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L601

Returns

AxProgramTrace<IN, OUT>[]

Implementation of

AxAgentic.getTraces


getUsage()

TypeScript
getUsage(): AxAgentUsage;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L649

Returns

AxAgentUsage

Implementation of

AxAgentic.getUsage


namedProgramInstances()

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

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L591

Returns

AxNamedProgramInstance<IN, OUT>[]

Implementation of

AxAgentic.namedProgramInstances


namedPrograms()

TypeScript
namedPrograms(): object[];

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L579

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/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L926

Parameters

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

Returns

Promise<AxAgentOptimizeResult<OUT>>


playbook()

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

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L972

The agent’s learned playbook — one evolving body of task knowledge bound to an agent stage (the actor/task stage by default). It grows three ways: continuously from each run (the playbook construction config), on demand via .update(...), or from a task set via .evolve(dataset, options) (verified by default). Unless apply is false, the rendered playbook is injected into the live stage prompt. Memoized — one playbook per agent. The evolution engine (ACE) is an implementation detail.

Parameters

ParameterType
options?Readonly<AxAgentPlaybookOptions>

Returns

AxAgentPlaybook<any, any>


resetUsage()

TypeScript
resetUsage(): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L713

Returns

void

Implementation of

AxAgentic.resetUsage


setContextMap()

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

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L729

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/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L613

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/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L570

Parameters

ParameterType
idstring

Returns

void

Implementation of

AxAgentic.setId


setSignature()

TypeScript
setSignature(signature: AxSignatureInput): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L781

Parameters

ParameterType
signatureAxSignatureInput

Returns

void


setState()

TypeScript
setState(state?: AxAgentState): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L721

Parameters

ParameterType
state?AxAgentState

Returns

void


stop()

TypeScript
stop(): void;

Defined in: https://github.com/ax-llm/ax/blob/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L559

Returns

void


streamingForward()

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

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

Run the agent once and stream its output.

Type Parameters

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

Parameters

ParameterTypeDescription
aiT-
valuesIN & objectSignature inputs plus an optional memories array with the same per-forward merge and reset semantics as forward().
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/e4219a44b7581a55a40d9dd62d2c281062ff078d/src/ax/agent/agentInternal/coordinator.ts#L1238

Parameters

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

Returns

Promise<AxAgentTestResult>

Docs