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

AxPlaybook

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/dsp/playbook.ts#L72

A live, evolving context playbook bound to a program.

Grow it offline from examples (evolve), keep it growing online from live feedback (update), render it into the program’s context (applyTo), and persist/restore it (toJSON/load).

Construct via the playbook factory.

Type Parameters

Type ParameterDefault type
INany
OUT extends AxGenOutAxGenOut

Constructors

Constructor

TypeScript
new AxPlaybook<IN, OUT>(program: Readonly<AxGen<IN, OUT>>, options: Readonly<AxPlaybookOptions>): AxPlaybook<IN, OUT>;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/dsp/playbook.ts#L79

Parameters

ParameterType
programReadonly<AxGen<IN, OUT>>
optionsReadonly<AxPlaybookOptions>

Returns

AxPlaybook<IN, OUT>

Methods

_setApplyHook()

TypeScript
_setApplyHook(hook: (rendered: string) => void): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/dsp/playbook.ts#L202

Internal

Redirect playbook injection. Used by agent.playbook() to push the rendered playbook into a pipeline stage instead of a bare program.

Parameters

ParameterType
hook(rendered: string) => void

Returns

void


applyTo()

TypeScript
applyTo(program?: Readonly<AxGen<IN, OUT>>): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/dsp/playbook.ts#L149

Render the current playbook into a program’s context (defaults to the bound program).

Parameters

ParameterType
program?Readonly<AxGen<IN, OUT>>

Returns

void


configureAuto()

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

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/dsp/playbook.ts#L188

Set the evolution intensity preset.

Parameters

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

Returns

void


evolve()

TypeScript
evolve(
   examples: readonly AxTypedExample<IN>[], 
   metricFn: AxMetricFn, 
options?: Readonly<AxPlaybookEvolveOptions>): Promise<AxPlaybookEvolveResult>;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/dsp/playbook.ts#L109

Grow the playbook offline from labeled examples, scoring each rollout with metricFn, then render the result into the bound program.

Parameters

ParameterType
examplesreadonly AxTypedExample<IN>[]
metricFnAxMetricFn
options?Readonly<AxPlaybookEvolveOptions>

Returns

Promise<AxPlaybookEvolveResult>


getState()

TypeScript
getState(): AxPlaybookSnapshot;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/dsp/playbook.ts#L163

A serializable snapshot of the current playbook and its history.

Returns

AxPlaybookSnapshot


load()

TypeScript
load(snapshot: Readonly<AxPlaybookSnapshot>): this;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/dsp/playbook.ts#L176

Restore a snapshot into this handle and render it into the bound program.

Parameters

ParameterType
snapshotReadonly<AxPlaybookSnapshot>

Returns

this


render()

TypeScript
render(): string;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/dsp/playbook.ts#L158

The current playbook rendered as a markdown block.

Returns

string


reset()

TypeScript
reset(): void;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/dsp/playbook.ts#L193

Clear the playbook back to its initial state.

Returns

void


toJSON()

TypeScript
toJSON(): AxPlaybookSnapshot;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/dsp/playbook.ts#L171

Alias of getState so JSON.stringify(handle) yields a snapshot.

Returns

AxPlaybookSnapshot


update()

TypeScript
update(args: Readonly<{
  example: AxExample;
  feedback?: string;
  prediction: unknown;
}>): Promise<void>;

Defined in: https://github.com/ax-llm/ax/blob/3306475085414d36aee4411ad2466e08e53bef8a/src/ax/dsp/playbook.ts#L130

Refine the playbook online from a single live interaction. Safe to call without a prior evolve/load — the bound program is hydrated lazily on first use.

Parameters

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

Returns

Promise<void>

Docs