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 Parameter | Default type |
|---|---|
IN | any |
OUT extends AxGenOut | AxGenOut |
Constructors
Constructor
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
| Parameter | Type |
|---|---|
program | Readonly<AxGen<IN, OUT>> |
options | Readonly<AxPlaybookOptions> |
Returns
AxPlaybook<IN, OUT>
Methods
_setApplyHook()
_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
| Parameter | Type |
|---|---|
hook | (rendered: string) => void |
Returns
void
applyTo()
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
| Parameter | Type |
|---|---|
program? | Readonly<AxGen<IN, OUT>> |
Returns
void
configureAuto()
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
| Parameter | Type |
|---|---|
level | "medium" | "light" | "heavy" |
Returns
void
evolve()
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
| Parameter | Type |
|---|---|
examples | readonly AxTypedExample<IN>[] |
metricFn | AxMetricFn |
options? | Readonly<AxPlaybookEvolveOptions> |
Returns
Promise<AxPlaybookEvolveResult>
getState()
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
load()
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
| Parameter | Type |
|---|---|
snapshot | Readonly<AxPlaybookSnapshot> |
Returns
this
render()
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()
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()
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
update()
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
| Parameter | Type |
|---|---|
args | Readonly<{ example: AxExample; feedback?: string; prediction: unknown; }> |
Returns
Promise<void>