@ax-llm/ax 22.0.7 → 22.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.cjs +368 -352
- package/index.cjs.map +1 -1
- package/index.d.cts +670 -3
- package/index.d.ts +670 -3
- package/index.global.js +253 -237
- package/index.global.js.map +1 -1
- package/index.js +368 -352
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/skills/ax-agent-context.md +42 -0
- package/skills/ax-agent-memory-skills.md +1 -1
- package/skills/ax-agent-observability.md +1 -1
- package/skills/ax-agent-optimize.md +4 -4
- package/skills/ax-agent-rlm.md +1 -1
- package/skills/ax-agent.md +1 -1
- package/skills/ax-ai.md +34 -8
- package/skills/ax-audio.md +1 -1
- package/skills/ax-flow.md +2 -2
- package/skills/ax-gen.md +2 -2
- package/skills/ax-gepa.md +5 -5
- package/skills/ax-llm.md +2 -2
- package/skills/ax-playbook.md +95 -0
- package/skills/ax-refine.md +1 -1
- package/skills/ax-signature.md +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ax-llm/ax",
|
|
3
|
-
"version": "22.0.
|
|
3
|
+
"version": "22.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The best library to work with LLMs",
|
|
6
6
|
"repository": {
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"import": "./index.js",
|
|
44
44
|
"require": "./index.cjs"
|
|
45
45
|
},
|
|
46
|
-
"./index.global.js": "./index.global.js",
|
|
47
46
|
"./*": {
|
|
48
47
|
"types": "./*.d.ts",
|
|
49
48
|
"import": "./*.js",
|
|
50
49
|
"require": "./*.cjs"
|
|
51
|
-
}
|
|
50
|
+
},
|
|
51
|
+
"./index.global.js": "./index.global.js"
|
|
52
52
|
},
|
|
53
53
|
"bin": {
|
|
54
54
|
"ax": "./cli/index.mjs"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ax-agent-context
|
|
3
|
+
description: This skill helps an LLM pick the right AxAgent context tool for a job - contextMap for recurring corpora, contextPolicy presets for within-run trajectory compaction, agent.optimize for offline GEPA instruction/demo tuning, agent.playbook for an evolving context playbook (offline evolve + online update), and recall/memories + skills for per-turn retrieval. Use when the user asks "which context feature should I use", confuses contextMap with contextPolicy or memory, or wants a decision guide for long-context agents. For contextPolicy/contextMap codegen use ax-agent-rlm; for recall/skills use ax-agent-memory-skills; for agent.optimize or agent.playbook use ax-agent-optimize.
|
|
4
|
+
version: "22.0.9"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# AxAgent Context Selection (@ax-llm/ax)
|
|
8
|
+
|
|
9
|
+
Use this skill to route a context-management need to the right AxAgent tool, then open the matching codegen skill. AxAgent manages four distinct context objects; choosing the wrong one is the usual mistake. Do not write tutorial prose; pick the tool and hand off.
|
|
10
|
+
|
|
11
|
+
## Pick The Right Context Tool
|
|
12
|
+
|
|
13
|
+
| Need | Object | Scope | Use | Next skill |
|
|
14
|
+
| --- | --- | --- | --- | --- |
|
|
15
|
+
| Many tasks over the same large corpus (repo, doc set, dataset) | Context map | recurring corpus, persists across runs | `contextMap` | `ax-agent-rlm` |
|
|
16
|
+
| One long run whose own history must stay under control | Trajectory compaction | this run only | `contextPolicy: { preset, budget }` | `ax-agent-rlm` |
|
|
17
|
+
| Evolve task strategy from examples or live feedback | Context playbook | a stage, offline + online | `agent.playbook(...)` | `ax-agent-optimize` |
|
|
18
|
+
| Tune the prompt/instructions/demos offline | Instruction text | a program, offline | `agent.optimize(...)` (GEPA) | `ax-agent-optimize` |
|
|
19
|
+
| Pull task-relevant facts or guides for a turn | Retrieval | one turn | `recall(...)` / skills | `ax-agent-memory-skills` |
|
|
20
|
+
|
|
21
|
+
## Defaults
|
|
22
|
+
|
|
23
|
+
- Recurring corpus + many different questions -> `contextMap` (persistent orientation cache).
|
|
24
|
+
- One long multi-turn run with prompt pressure -> `contextPolicy: { preset: 'checkpointed', budget: 'balanced' }`; move to `lean` for very long runs with strong models, `full` for short tasks or weak models.
|
|
25
|
+
- Evolve a context playbook -> `agent.playbook(...)` (offline from examples, or online from live feedback).
|
|
26
|
+
- Tune instructions/demos offline -> `agent.optimize(...)` (GEPA).
|
|
27
|
+
- Fetch facts or guides on demand -> `recall(...)` for memories, `discover({ skills })` for skill guides.
|
|
28
|
+
|
|
29
|
+
## Anti-Patterns
|
|
30
|
+
|
|
31
|
+
- Do not use `contextMap` to compress a single run's history. That is `contextPolicy`.
|
|
32
|
+
- Do not use `contextPolicy` to carry knowledge across runs. That is `contextMap`.
|
|
33
|
+
- Do not hand-build a strategy playbook in the prompt. Evolve it with `agent.playbook(...)`.
|
|
34
|
+
- Do not stuff a whole corpus into the prompt every run. Use a context map plus on-demand `recall(...)`.
|
|
35
|
+
- Do not confuse runtime skills (`discover({ skills })` guides) with these installable codegen skills.
|
|
36
|
+
|
|
37
|
+
## See Also
|
|
38
|
+
|
|
39
|
+
- `ax-agent-rlm` - contextPolicy presets, context maps, and runtime sessions.
|
|
40
|
+
- `ax-agent-memory-skills` - recall, memories, and dynamic skill loading.
|
|
41
|
+
- `ax-agent-optimize` - GEPA via `agent.optimize(...)` and the context playbook via `agent.playbook(...)`.
|
|
42
|
+
- `ax-agent` - core agent shape and the final/clarification protocol.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-agent-memory-skills
|
|
3
3
|
description: This skill helps an LLM generate correct AxAgent memory retrieval, context-map, and dynamic skill-loading code using @ax-llm/ax. Use when the user asks about contextMap, AxAgentContextMap, onMemoriesSearch, recall(...), inputs.memories, onLoadedMemories, onUsedMemories, onSkillsSearch, discover({ skills }), onLoadedSkills, onUsedSkills, preloaded skills, loaded memory/skill IDs, or carrying memories across forward() calls.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Memory And Skills Rules (@ax-llm/ax)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-agent-observability
|
|
3
3
|
description: This skill helps an LLM generate correct AxAgent observability code using @ax-llm/ax. Use when the user asks about actorTurnCallback, onContextEvent, agentStatusCallback, onFunctionCall, reportSuccess, reportFailure, getChatLog(), getUsage(), resetUsage(), debug traces, progress updates, or telemetry for AxAgent runs.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Observability Rules (@ax-llm/ax)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-agent-optimize
|
|
3
3
|
description: This skill helps an LLM generate correct AxAgent tuning and evaluation code using @ax-llm/ax. Use when the user asks about agent.optimize(...), judgeOptions, eval datasets, optimization targets, saved optimizedProgram artifacts, or agent optimization guidance.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Optimize Codegen Rules (@ax-llm/ax)
|
|
@@ -136,13 +136,13 @@ const tools = [
|
|
|
136
136
|
const studentAI = ai({
|
|
137
137
|
name: 'google-gemini',
|
|
138
138
|
apiKey: process.env.GOOGLE_APIKEY!,
|
|
139
|
-
config: { model: AxAIGoogleGeminiModel.
|
|
139
|
+
config: { model: AxAIGoogleGeminiModel.Gemini31FlashLite, temperature: 0.2 },
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
const judgeAI = ai({
|
|
143
143
|
name: 'google-gemini',
|
|
144
144
|
apiKey: process.env.GOOGLE_APIKEY!,
|
|
145
|
-
config: { model: AxAIGoogleGeminiModel.
|
|
145
|
+
config: { model: AxAIGoogleGeminiModel.Gemini35Flash, temperature: 1.0 },
|
|
146
146
|
});
|
|
147
147
|
|
|
148
148
|
const assistant = agent('query:string -> answer:string', {
|
|
@@ -246,7 +246,7 @@ Use this when the agent behavior needs holistic review:
|
|
|
246
246
|
const result = await assistant.optimize(tasks, {
|
|
247
247
|
judgeAI,
|
|
248
248
|
judgeOptions: {
|
|
249
|
-
model: AxAIGoogleGeminiModel.
|
|
249
|
+
model: AxAIGoogleGeminiModel.Gemini35Flash,
|
|
250
250
|
description:
|
|
251
251
|
'Be strict about unnecessary child-agent calls, weak clarifications, and incorrect tool choices.',
|
|
252
252
|
},
|
package/skills/ax-agent-rlm.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-agent-rlm
|
|
3
3
|
description: This skill helps an LLM generate correct AxAgent RLM/runtime code using @ax-llm/ax. Use when the user asks about RLM code execution, AxJSRuntime, contextFields, contextPolicy, liveRuntimeState, promptLevel, stage prompt controls, executorModelPolicy, maxRuntimeChars, agent.test(...), llmQuery(...), recursionOptions, or long-running agent runtime behavior.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent RLM Runtime Rules (@ax-llm/ax)
|
package/skills/ax-agent.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-agent
|
|
3
3
|
description: This skill helps an LLM generate correct core AxAgent code using @ax-llm/ax. Use when the user asks about agent(), child agents, namespaced functions, discovery mode, clarification, bubbleErrors, host-side final/clarification protocol, or ordinary agent runtime behavior. For RLM/code-runtime work use ax-agent-rlm; for callbacks and telemetry use ax-agent-observability; for recall/memory/skill loading use ax-agent-memory-skills; for agent.optimize(...) use ax-agent-optimize.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Codegen Rules (@ax-llm/ax)
|
package/skills/ax-ai.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-ai
|
|
3
3
|
description: This skill helps an LLM generate correct AI provider setup and configuration code using @ax-llm/ax. Use when the user asks about ai(), providers, models, presets, embeddings, batch audio with ai.transcribe() or ai.speak(), extended thinking, context caching, or mentions OpenAI/Anthropic/Google/Azure/DeepSeek/Mistral/Cohere/Reka/Grok with @ax-llm/ax.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AI Provider Codegen Rules (@ax-llm/ax)
|
|
@@ -16,7 +16,7 @@ import { ai } from '@ax-llm/ax';
|
|
|
16
16
|
const openai = ai({ name: 'openai', apiKey: 'sk-...' });
|
|
17
17
|
const claude = ai({ name: 'anthropic', apiKey: 'sk-ant-...' });
|
|
18
18
|
const gemini = ai({ name: 'google-gemini', apiKey: 'AIza...' });
|
|
19
|
-
const azure = ai({ name: 'azure-openai', apiKey: 'your-key', resourceName: 'your-resource', deploymentName: 'gpt-4' });
|
|
19
|
+
const azure = ai({ name: 'azure-openai', apiKey: 'your-key', resourceName: 'your-resource', deploymentName: 'gpt-5-4-mini' });
|
|
20
20
|
const deepseek = ai({ name: 'deepseek', apiKey: 'sk-...' });
|
|
21
21
|
const mistral = ai({ name: 'mistral', apiKey: 'your-key' });
|
|
22
22
|
const cohere = ai({ name: 'cohere', apiKey: 'your-key' });
|
|
@@ -31,6 +31,28 @@ const grok = ai({ name: 'grok', apiKey: 'your-key' });
|
|
|
31
31
|
const compatible = ai({ name: 'openai', apiKey: 'key', apiURL: 'https://api.example.com/v1', config: { model: 'provider/model' } });
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
<!-- axir-nonportable:start webllm -->
|
|
35
|
+
WebLLM is browser-only and requires a host-created WebLLM engine. The host
|
|
36
|
+
loads or reloads models with WebLLM APIs such as `CreateMLCEngine(...)`; Ax
|
|
37
|
+
only forwards chat requests to that loaded engine. Do not present WebLLM as a
|
|
38
|
+
portable AxIR provider or a server-side default.
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { ai, AxAIWebLLMModel } from '@ax-llm/ax';
|
|
42
|
+
|
|
43
|
+
const engine = await CreateMLCEngine(AxAIWebLLMModel.Llama32_3B_Instruct);
|
|
44
|
+
const llm = ai({
|
|
45
|
+
name: 'webllm',
|
|
46
|
+
engine,
|
|
47
|
+
config: {
|
|
48
|
+
model: AxAIWebLLMModel.Llama32_3B_Instruct,
|
|
49
|
+
stream: false,
|
|
50
|
+
supportsFunctions: false,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
<!-- axir-nonportable:end webllm -->
|
|
55
|
+
|
|
34
56
|
## Model Presets
|
|
35
57
|
|
|
36
58
|
```typescript
|
|
@@ -41,8 +63,8 @@ const gemini = ai({
|
|
|
41
63
|
apiKey: process.env.GOOGLE_APIKEY!,
|
|
42
64
|
config: { model: 'simple' },
|
|
43
65
|
models: [
|
|
44
|
-
{ key: 'tiny', model: AxAIGoogleGeminiModel.
|
|
45
|
-
{ key: 'simple', model: AxAIGoogleGeminiModel.
|
|
66
|
+
{ key: 'tiny', model: AxAIGoogleGeminiModel.Gemini31FlashLite, description: 'Fast + cheap', config: { maxTokens: 1024, temperature: 0.3 } },
|
|
67
|
+
{ key: 'simple', model: AxAIGoogleGeminiModel.Gemini35Flash, description: 'Balanced', config: { temperature: 0.6 } },
|
|
46
68
|
],
|
|
47
69
|
});
|
|
48
70
|
|
|
@@ -284,22 +306,26 @@ import { AxAIBedrock, AxAIBedrockModel } from '@ax-llm/ax-ai-aws-bedrock';
|
|
|
284
306
|
const bedrock = new AxAIBedrock({
|
|
285
307
|
region: 'us-east-2',
|
|
286
308
|
fallbackRegions: ['us-west-2'],
|
|
287
|
-
config: { model: AxAIBedrockModel.
|
|
309
|
+
config: { model: AxAIBedrockModel.ClaudeOpus45 },
|
|
288
310
|
});
|
|
289
311
|
```
|
|
290
312
|
|
|
291
313
|
## Vercel AI SDK Integration
|
|
292
314
|
|
|
293
315
|
```typescript
|
|
316
|
+
import { generateText } from 'ai';
|
|
294
317
|
import { ai } from '@ax-llm/ax';
|
|
295
318
|
import { AxAIProvider } from '@ax-llm/ax-ai-sdk-provider';
|
|
296
|
-
import { generateText } from 'ai';
|
|
297
319
|
|
|
298
|
-
const axAI = ai({
|
|
320
|
+
const axAI = ai({
|
|
321
|
+
name: 'openai',
|
|
322
|
+
apiKey: process.env.OPENAI_APIKEY ?? '',
|
|
323
|
+
});
|
|
299
324
|
const model = new AxAIProvider(axAI);
|
|
325
|
+
|
|
300
326
|
const result = await generateText({
|
|
301
327
|
model,
|
|
302
|
-
|
|
328
|
+
prompt: 'Hello!',
|
|
303
329
|
});
|
|
304
330
|
```
|
|
305
331
|
|
package/skills/ax-audio.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-audio
|
|
3
3
|
description: This skill helps an LLM generate correct audio code with @ax-llm/ax. Use when the user asks about ai.transcribe(), ai.speak(), signature audio inputs or outputs, agent audio behavior, .chat() conversational audio, OpenAI audio or realtime models, Gemini Live native audio, Grok Voice Agent models, voices, formats, transcripts, or how audio fits with structured outputs.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Audio I/O Codegen Rules (@ax-llm/ax)
|
package/skills/ax-flow.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-flow
|
|
3
3
|
description: This skill helps an LLM generate correct AxFlow workflow code using @ax-llm/ax. Use when the user asks about flow(), AxFlow, workflow orchestration, parallel execution, DAG workflows, conditional routing, map/reduce patterns, or multi-node AI pipelines.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxFlow Codegen Rules (@ax-llm/ax)
|
|
@@ -305,7 +305,7 @@ const wf = flow<{ items: string[] }, { processed: string[] }>({ batchSize: 3 })
|
|
|
305
305
|
Route nodes to different AI providers:
|
|
306
306
|
|
|
307
307
|
```typescript
|
|
308
|
-
const fast = ai({ name: 'openai', apiKey: '...', config: { model: 'gpt-5-mini' } });
|
|
308
|
+
const fast = ai({ name: 'openai', apiKey: '...', config: { model: 'gpt-5.4-mini' } });
|
|
309
309
|
const smart = ai({ name: 'anthropic', apiKey: '...' });
|
|
310
310
|
|
|
311
311
|
const wf = flow<{ text: string }, { out: string }>()
|
package/skills/ax-gen.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-gen
|
|
3
3
|
description: This skill helps an LLM generate correct AxGen code using @ax-llm/ax. Use when the user asks about ax(), AxGen, generators, forward(), streamingForward(), validation, assertions, streaming assertions, field processors, step hooks, self-tuning, or structured outputs.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxGen Codegen Rules (@ax-llm/ax)
|
|
@@ -111,7 +111,7 @@ const result = await gen.forward(llm, { input: '...' });
|
|
|
111
111
|
// With options
|
|
112
112
|
const result = await gen.forward(llm, { input: '...' }, {
|
|
113
113
|
maxRetries: 5,
|
|
114
|
-
model: 'gpt-4
|
|
114
|
+
model: 'gpt-5.4-mini',
|
|
115
115
|
modelConfig: { temperature: 0.9, maxTokens: 1000 },
|
|
116
116
|
debug: true,
|
|
117
117
|
});
|
package/skills/ax-gepa.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-gepa
|
|
3
3
|
description: This skill helps an LLM generate correct AxGEPA optimization code using @ax-llm/ax. Use when the user asks about AxGEPA, GEPA, Pareto optimization, multi-objective prompt tuning, reflective prompt evolution, validationExamples, maxMetricCalls, or optimizing a generator, flow, or agent tree.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# GEPA Optimization Codegen Rules (@ax-llm/ax)
|
|
@@ -57,13 +57,13 @@ import { ai, ax, optimize, AxAIOpenAIModel } from '@ax-llm/ax';
|
|
|
57
57
|
const student = ai({
|
|
58
58
|
name: 'openai',
|
|
59
59
|
apiKey: process.env.OPENAI_APIKEY!,
|
|
60
|
-
config: { model: AxAIOpenAIModel.
|
|
60
|
+
config: { model: AxAIOpenAIModel.GPT54Mini },
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
const teacher = ai({
|
|
64
64
|
name: 'openai',
|
|
65
65
|
apiKey: process.env.OPENAI_APIKEY!,
|
|
66
|
-
config: { model: AxAIOpenAIModel.
|
|
66
|
+
config: { model: AxAIOpenAIModel.GPT54 },
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
const classifier = ax(
|
|
@@ -107,13 +107,13 @@ import { ai, flow, optimize, AxAIOpenAIModel } from '@ax-llm/ax';
|
|
|
107
107
|
const student = ai({
|
|
108
108
|
name: 'openai',
|
|
109
109
|
apiKey: process.env.OPENAI_APIKEY!,
|
|
110
|
-
config: { model: AxAIOpenAIModel.
|
|
110
|
+
config: { model: AxAIOpenAIModel.GPT54Mini },
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
const teacher = ai({
|
|
114
114
|
name: 'openai',
|
|
115
115
|
apiKey: process.env.OPENAI_APIKEY!,
|
|
116
|
-
config: { model: AxAIOpenAIModel.
|
|
116
|
+
config: { model: AxAIOpenAIModel.GPT54 },
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
const wf = flow<{ emailText: string }>()
|
package/skills/ax-llm.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-llm
|
|
3
3
|
description: This skill helps with using the @ax-llm/ax TypeScript library for building LLM applications. Use when the user asks about ax(), ai(), f(), s(), agent(), flow(), AxGen, AxAgent, AxFlow, signatures, streaming, or mentions @ax-llm/ax.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Ax Library (@ax-llm/ax) Quick Reference
|
|
@@ -90,7 +90,7 @@ for await (const chunk of gen.streamingForward(llm, { question: 'Tell a story' }
|
|
|
90
90
|
|
|
91
91
|
| Goal | Option | Example |
|
|
92
92
|
|------|--------|---------|
|
|
93
|
-
| Model override | `model` | `{ model: 'gpt-
|
|
93
|
+
| Model override | `model` | `{ model: 'gpt-5.4-mini' }` |
|
|
94
94
|
| Temperature | `modelConfig.temperature` | `{ modelConfig: { temperature: 0.8 } }` |
|
|
95
95
|
| Max tokens | `modelConfig.maxTokens` | `{ modelConfig: { maxTokens: 500 } }` |
|
|
96
96
|
| Retry on failure | `maxRetries` | `{ maxRetries: 3 }` |
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ax-playbook
|
|
3
|
+
description: This skill helps an LLM generate correct playbook code using @ax-llm/ax. Use when the user asks about playbook(), AxPlaybook, context playbooks, evolving context, ACE / Agentic Context Engineering, agent.playbook(), or growing/applying task knowledge offline and online with evolve() and update().
|
|
4
|
+
version: "22.0.9"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Playbook Codegen Rules (@ax-llm/ax)
|
|
8
|
+
|
|
9
|
+
Use this skill to generate context-playbook code. A playbook grows an evolving body of task knowledge and renders it into a program's context. The evolution engine (ACE — Agentic Context Engineering) is hidden behind `playbook(...)`, exactly as `optimize(...)` hides its optimizer. Prefer the `playbook(...)` concept; only reach for `AxACE` directly when the user explicitly wants the low-level engine.
|
|
10
|
+
|
|
11
|
+
## Use These Defaults
|
|
12
|
+
|
|
13
|
+
- Create with `playbook(program, { studentAI, teacherAI? })`; it returns an `AxPlaybook` handle.
|
|
14
|
+
- Grow offline with `await pb.evolve(examples, metric)` — returns `{ bestScore, playbook }`.
|
|
15
|
+
- Grow online with `await pb.update({ example, prediction, feedback })` — no metric needed.
|
|
16
|
+
- Apply with `pb.applyTo(program)` (defaults to the bound program).
|
|
17
|
+
- Persist with `pb.toJSON()` and restore with `playbook(program, opts).load(snapshot)`.
|
|
18
|
+
- Inspect with `pb.render()` (markdown) and `pb.getState()` (`{ playbook, artifact }`).
|
|
19
|
+
- For agents use `agent.playbook({ target: 'actor' | 'responder' })`; default target is `'actor'`.
|
|
20
|
+
- Use a cheaper `studentAI` to run the program and an optional stronger `teacherAI` to reflect/curate.
|
|
21
|
+
- Prefer `ai()`, `ax()`, and `agent()` for new code.
|
|
22
|
+
|
|
23
|
+
## Critical Rules
|
|
24
|
+
|
|
25
|
+
- `playbook(...)` binds to an `AxGen` program; `evolve`/`update` need that program's signature.
|
|
26
|
+
- `evolve()` returns only `{ bestScore, playbook }`. There is no Pareto front and no `optimizedProgram` — that is `optimize(...)`'s shape, not a playbook's.
|
|
27
|
+
- `update({ example, prediction, feedback })` requires the full `{ example, prediction }`; `example` must match the program's input fields (plus any expected output). Do not pass bare input fields at the top level.
|
|
28
|
+
- `update()` works without a prior `evolve()`/`load()` — the handle hydrates lazily on first use.
|
|
29
|
+
- `applyTo()` injects a `## Context Playbook` block into the program description; calling it repeatedly recomposes from the original base (no stacking).
|
|
30
|
+
- Keep the offline `metric` deterministic and cheap, like a GEPA metric.
|
|
31
|
+
- A playbook is plain JSON. Persist `pb.toJSON()` and `load(...)` it into a fresh program for production.
|
|
32
|
+
- This is a TypeScript feature; do not suggest it for the generated (Python/Go/Rust/Java/C++) packages yet.
|
|
33
|
+
|
|
34
|
+
## Offline Pattern (evolve)
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { type AxMetricFn, ai, ax, playbook } from '@ax-llm/ax';
|
|
38
|
+
|
|
39
|
+
const program = ax('review:string -> sentiment:class "positive, negative"');
|
|
40
|
+
const studentAI = ai({ name: 'openai', apiKey: process.env.OPENAI_APIKEY! });
|
|
41
|
+
const metric: AxMetricFn = ({ prediction, example }) =>
|
|
42
|
+
(prediction as any).sentiment === (example as any).sentiment ? 1 : 0;
|
|
43
|
+
|
|
44
|
+
const pb = playbook(program, { studentAI, maxEpochs: 2 });
|
|
45
|
+
const { bestScore } = await pb.evolve(train, metric);
|
|
46
|
+
pb.applyTo(program);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Online Pattern (update)
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// After a real run, feed the outcome back so the playbook keeps learning.
|
|
53
|
+
await pb.update({
|
|
54
|
+
example: { review: 'Five stars, would buy again.' },
|
|
55
|
+
prediction: { sentiment: 'negative' },
|
|
56
|
+
feedback: 'WRONG: enthusiastic praise is positive.',
|
|
57
|
+
});
|
|
58
|
+
pb.applyTo(program);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Persist And Restore
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
const snapshot = pb.toJSON(); // { playbook, artifact } — plain JSON
|
|
65
|
+
// later, in another process / a production program instance:
|
|
66
|
+
playbook(prodProgram, { studentAI }).load(snapshot).applyTo(prodProgram);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Agents
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const a = agent('ticket:string -> reply:string', { ai });
|
|
73
|
+
const apb = a.playbook({ target: 'actor' }); // 'actor' (default) or 'responder'
|
|
74
|
+
await apb.update({ example, prediction, feedback }); // injected into the live stage prompt
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Offline `evolve(...)` on an agent stage scores that stage in isolation; for full-pipeline tuning of agent instructions and demos use `agent.optimize(...)` (GEPA).
|
|
78
|
+
|
|
79
|
+
## Playbook vs optimize()
|
|
80
|
+
|
|
81
|
+
- `playbook(...)` — accumulate reusable, evolving task knowledge; the only path that also learns online via `update(...)`.
|
|
82
|
+
- `optimize(...)` / `agent.optimize(...)` — tune instruction text and few-shot demos offline to a best/Pareto result.
|
|
83
|
+
- They are complementary; a project can use both.
|
|
84
|
+
|
|
85
|
+
## Troubleshooting
|
|
86
|
+
|
|
87
|
+
- "Cannot convert undefined or null to object" from `update()` → you passed input fields at the top level; wrap them in `example: { ... }`.
|
|
88
|
+
- Empty playbook after `evolve()` → the model already scored well, so nothing was curated; use harder/ambiguous examples or a weaker `studentAI` to surface lessons.
|
|
89
|
+
- Playbook not affecting an agent's behavior → ensure `apply` is not `false` and you used `agent.playbook(...)` (not a bare `playbook()` on an internal program).
|
|
90
|
+
|
|
91
|
+
## See Also
|
|
92
|
+
|
|
93
|
+
- `ax-gepa` - `optimize(...)` and `AxGEPA` for instruction/demo tuning.
|
|
94
|
+
- `ax-agent-context` - choosing between contextMap, contextPolicy, `agent.playbook(...)`, and recall.
|
|
95
|
+
- `ax-agent-optimize` - `agent.optimize(...)` GEPA tuning for agents.
|
package/skills/ax-refine.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-refine
|
|
3
3
|
description: Use this skill when writing or reviewing Ax bestOfN/refine code, reward functions, thresholds, native sample selection, serial attempts, generated advice, and attempt diagnostics.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Ax Refine And BestOfN
|
package/skills/ax-signature.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-signature
|
|
3
3
|
description: This skill helps an LLM generate correct DSPy signature code using @ax-llm/ax. Use when the user asks about signatures, s(), f(), field types, string syntax, fluent builder API, validation constraints, or type-safe inputs/outputs.
|
|
4
|
-
version: "22.0.
|
|
4
|
+
version: "22.0.9"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Ax Signature Reference
|