@ax-llm/ax 21.0.14 → 22.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ax-llm/ax",
3
- "version": "21.0.14",
3
+ "version": "22.0.0",
4
4
  "type": "module",
5
5
  "description": "The best library to work with LLMs",
6
6
  "repository": {
@@ -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: "21.0.14"
4
+ version: "22.0.0"
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
- description: This skill helps an LLM generate correct AxAgent observability code using @ax-llm/ax. Use when the user asks about actorTurnCallback, executorTurnCallback, onContextEvent, agentStatusCallback, onFunctionCall, reportSuccess, reportFailure, getChatLog(), getUsage(), resetUsage(), debug traces, progress updates, or telemetry for AxAgent runs.
4
- version: "21.0.14"
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.0"
5
5
  ---
6
6
 
7
7
  # AxAgent Observability Rules (@ax-llm/ax)
@@ -38,7 +38,7 @@ These globals are live defaults for future AI, AxGen, AxFlow, and agent-internal
38
38
 
39
39
  ## Actor Turn Callback
40
40
 
41
- Use `actorTurnCallback` when the caller needs structured telemetry for each actor turn. `executorTurnCallback` is still accepted as a deprecated alias for older code.
41
+ Use `actorTurnCallback` when the caller needs structured telemetry for each actor turn.
42
42
 
43
43
  What it gives you:
44
44
 
@@ -127,7 +127,7 @@ actorTurnCallback?: (turn: {
127
127
  chatLogMessages?: ReadonlyArray<{ role: string; content: string }>;
128
128
  }) => void | Promise<void>;
129
129
 
130
- executorTurnCallback?: (turn: {
130
+ actorTurnCallback?: (turn: {
131
131
  stage: 'distiller' | 'executor';
132
132
  turn: number;
133
133
  actionLogEntryCount: number;
@@ -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: "21.0.14"
4
+ version: "22.0.0"
5
5
  ---
6
6
 
7
7
  # AxAgent Optimize Codegen Rules (@ax-llm/ax)
@@ -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: "21.0.14"
4
+ version: "22.0.0"
5
5
  ---
6
6
 
7
7
  # AxAgent RLM Runtime Rules (@ax-llm/ax)
@@ -30,11 +30,11 @@ Use this skill for code-runtime agents and `llmQuery(...)` semantic-helper behav
30
30
  distiller (RLM actor) -> executor (RLM actor) -> responder (synthesizer)
31
31
  ```
32
32
 
33
- - **distiller** always runs first. It sees all original inputs so it can understand and normalize the task; declared `contextFields` stay runtime-only when present. It distils relevant evidence by writing JS code in a multi-turn loop, then calls `final(request, evidence)`. The request becomes the executor's `inputs.executorRequest`; it must be self-contained and restate the concrete action, target, and constraints, not vague wording like "do it". The distiller should expand the original user task with facts found in context, including follow-ups like "yes, do it". When no `contextFields` are configured, it still performs request normalization over the original inputs with `contextFields: []`. **The distiller has no tools and is not a capability gate.**
33
+ - **distiller** always runs first. It sees all original inputs so it can understand and normalize the task; declared `contextFields` stay runtime-only when present. It distils relevant evidence by writing runtime-language code in a multi-turn loop, then calls the runtime-exposed `final(request, evidence)` primitive. The request becomes the executor's `inputs.executorRequest`; it must be self-contained and restate the concrete action, target, and constraints, not vague wording like "do it". The distiller should expand the original user task with facts found in context, including follow-ups like "yes, do it". When no `contextFields` are configured, it still performs request normalization over the original inputs with `contextFields: []`. **The distiller has no tools and is not a capability gate.**
34
34
  - **executor** always runs. It receives non-context inputs plus `inputs.executorRequest` and `inputs.distilledContext` from the distiller's `final(request, evidence)` payload. Raw context fields are not present in the executor stage. The executor owns tool use, decides whether to call its available functions or finish directly from distilled evidence, and reports actual tool results or failures.
35
35
  - **responder** always runs last. It synthesizes the user's output signature from whichever upstream actor finished the run and must not contradict tool evidence gathered upstream.
36
36
 
37
- Treat both actor stages as long-running JavaScript REPLs that the actor steers over multiple turns, not as fresh script generators on every turn.
37
+ Treat both actor stages as long-running code runtime sessions that the actor steers over multiple turns, not as fresh script generators on every turn. `AxJSRuntime` is the default; custom runtimes set `language` so the actor code field becomes `<language>Code` such as `pythonCode` while JavaScript keeps the legacy `javascriptCode`.
38
38
 
39
39
  - Successful code leaves variables, functions, imports, and computed values available in the runtime session.
40
40
  - The actor should continue from existing runtime state instead of recreating prior work.
@@ -43,7 +43,7 @@ Treat both actor stages as long-running JavaScript REPLs that the actor steers o
43
43
 
44
44
  ## RLM Actor Code Rules
45
45
 
46
- Use these rules when generating actor JavaScript for RLM in stdout mode:
46
+ Use these rules when generating actor JavaScript for RLM in `AxJSRuntime` stdout mode. For custom runtimes, follow the runtime's `getUsageInstructions()`, primitive overrides, and callable formatter instead.
47
47
 
48
48
  - Treat each actor turn as exactly one observable step.
49
49
  - Inspect what already exists before recomputing it. If a prior turn successfully created a value, prefer reusing that runtime value.
@@ -246,6 +246,14 @@ Model guidance:
246
246
  - For cost-sensitive setups, a common pattern is stronger actor plus cheaper responder.
247
247
  - Prefer `executorModelPolicy` over globally upgrading the whole agent when the actor only needs help after context grows or the run starts thrashing.
248
248
 
249
+ Prompt/cache shape:
250
+
251
+ - Actor turns are compact observable turns, not replayed chat transcripts.
252
+ - Stable system prompt: role/stage rules, primitive descriptions, static module list, always-included callable signatures, output contract, and field definitions.
253
+ - Cached working inputs: task inputs, inline context, `contextMetadata`, `contextMap`, `memories`, `executorRequest`, `distilledContext`, `discoveredToolDocs`, `loadedSkills`, and `summarizedActorLog`.
254
+ - Dynamic turn tail: `guidanceLog`, `actionLog`, `liveRuntimeState`, and `contextPressure`.
255
+ - Prefer one compact inspection per non-final turn. Never combine inspection output with `final(...)` or `askClarification(...)`.
256
+
249
257
  Invalid actor turn:
250
258
 
251
259
  ```javascript
@@ -260,6 +268,8 @@ Reason: this mixes observation and follow-up work in one turn. `discover(...)` r
260
268
 
261
269
  Default `new AxJSRuntime()` is hardened: no network, no filesystem, no child process, dynamic `import()` blocked, intrinsics frozen, `ShadowRealm` locked to `undefined`, worker IPC locked in browser/Deno/Bun, Bun workers use `smol: true`, and on Node 20+ the OS Permission Model auto-engages where available.
262
270
 
271
+ Threat model: this is defense-in-depth for LLM-authored code, not a container or VM boundary. Host callbacks and granted runtime permissions remain the authority boundary; keep durable secrets and privileged effects in host-side functions.
272
+
263
273
  Permission enum (`AxJSRuntimePermission`):
264
274
  `NETWORK`, `STORAGE`, `CODE_LOADING`, `COMMUNICATION`, `TIMING`, `WORKERS`, `FILESYSTEM`, `CHILD_PROCESS`.
265
275
 
@@ -267,7 +277,7 @@ Options quick reference:
267
277
 
268
278
  - `permissions?: readonly AxJSRuntimePermission[]`: default `[]`; opt in capabilities.
269
279
  - `blockDynamicImport?: boolean`: default `true`.
270
- - `allowedModules?: readonly string[]`: default `[]`.
280
+ - `allowedModules?: readonly string[]`: default `[]`; narrow dynamic-import allowlist gate. Allowlisted specifiers are attempted, but full Node module namespace passthrough depends on Node vm semantics.
271
281
  - `freezeIntrinsics?: boolean`: default `true`.
272
282
  - `blockShadowRealm?: boolean`: default `true`.
273
283
  - `lockWorkerIPC?: boolean`: default `true`.
@@ -300,15 +310,25 @@ Rules for the LLM author:
300
310
 
301
311
  - Default to `new AxJSRuntime()` with no options unless the user asked for a specific capability.
302
312
  - When the user asks for `fetch`, add `permissions: [AxJSRuntimePermission.NETWORK]`.
303
- - When the user asks for filesystem access, add both `permissions: [AxJSRuntimePermission.FILESYSTEM]` and `allowedModules: ['node:fs', 'node:fs/promises', 'node:path']`. Scope with `nodePermissionAllowlist` when the user names a directory.
313
+ - When the user asks for filesystem access, prefer host-side tool functions. If direct runtime filesystem access is required, add `permissions: [AxJSRuntimePermission.FILESYSTEM]`, scope with `nodePermissionAllowlist` when the user names a directory, and treat `allowedModules` as an import allowlist gate rather than a portability guarantee.
304
314
  - Do not disable `freezeIntrinsics`, `blockShadowRealm`, or `lockWorkerIPC` unless the user explicitly asks.
305
315
  - Treat `allowUnsafeNodeHostAccess: true` as a red flag; only use it when the user is authoring trusted code in their own process.
306
316
  - `preventGlobalThisExtensions: true` breaks top-level `var`/`let`/`const` persistence across turns; never set it for stdout-mode RLM where persistence is load-bearing.
307
317
  - On Deno, `blockDynamicImport` is a no-op; the defense is the worker permission sandbox. Pass `allowDenoRemoteImport: true` only if remote module loading is genuinely required.
308
318
 
319
+ ## Custom Code Runtimes
320
+
321
+ Implement `AxCodeRuntime` when the actor should write a language other than JavaScript.
322
+
323
+ - Set `language` to the model-facing language name. JavaScript aliases (`JavaScript`, `js`, `ecmascript`) keep `javascriptCode`; other values derive lower-camel code fields such as `pythonCode` or `cSharpCode`.
324
+ - Keep execution inside `createSession(globals, options)`. AxAgent passes `inputs`, `llmQuery`, `final`, `askClarification`, progress callbacks, memory/discovery primitives, and namespaced tools as host globals; the runtime decides how those globals appear in the target language.
325
+ - Put language syntax, output behavior, persistence semantics, and completion-call examples in `getUsageInstructions()`.
326
+ - Use `getPrimitiveOverrides()` to describe language-native calls for built-in primitives, and `formatCallable()` to describe language-native calls for tools and child agents.
327
+ - Implement `inspectGlobals()` on sessions when `contextPolicy` should show live runtime state for non-JavaScript runtimes; otherwise AxAgent will not run JavaScript fallback inspection snippets.
328
+
309
329
  ## RLM Test Harness
310
330
 
311
- Use `agent.test(code, contextFieldValues?, options?)` when the user wants to validate JavaScript snippets against the actual AxAgent runtime environment without running the full actor/responder loop.
331
+ Use `agent.test(code, contextFieldValues?, options?)` when the user wants to validate runtime snippets against the actual AxAgent runtime environment without running the full actor/responder loop. With `AxJSRuntime`, those snippets are JavaScript.
312
332
 
313
333
  ```typescript
314
334
  import { AxJSRuntime, agent, f, fn } from '@ax-llm/ax';
@@ -365,7 +385,7 @@ Rules:
365
385
 
366
386
  - `llmQuery(...)` forwards only the explicit `context` argument.
367
387
  - Parent inputs, runtime variables, tool results, and discovered docs are not automatically available to `llmQuery(...)`; include any needed facts in `context`.
368
- - `llmQuery(...)` is a direct semantic helper backed by an AxGen sub-query. It does not create a child AxAgent, does not run a JS runtime, and does not have access to tools or discovery.
388
+ - `llmQuery(...)` is a direct semantic helper backed by an AxGen sub-query. It does not create a child AxAgent, does not run an actor runtime session, and does not have access to tools or discovery.
369
389
  - Use batched `llmQuery([...])` only for independent semantic questions. Use serial calls when later work depends on earlier results.
370
390
  - Pass compact named object context instead of huge raw parent payloads.
371
391
  - Do not assume anything other than the returned string comes back from `llmQuery(...)`.
@@ -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: "21.0.14"
4
+ version: "22.0.0"
5
5
  ---
6
6
 
7
7
  # AxAgent Codegen Rules (@ax-llm/ax)
@@ -118,7 +118,7 @@ Use direct `ax(...)` or `.chat()` if the model should receive native audio inste
118
118
 
119
119
  ## Child Agents As Tools
120
120
 
121
- Child agents are passed in the parent's `functions` list. There is no separate `agents` option for new code. Each child agent's `agentIdentity.namespace` (or `utils`, the default) determines where it lands in the JS runtime:
121
+ Child agents are passed in the parent's `functions` list. There is no separate `agents` option for new code. Each child agent's `agentIdentity.namespace` (or `utils`, the default) determines where it lands in the actor runtime. With `AxJSRuntime`, that produces JavaScript call sites such as `team.writer(...)`:
122
122
 
123
123
  ```typescript
124
124
  const writer = agent('draft:string -> revision:string', {
@@ -156,7 +156,7 @@ Rules:
156
156
 
157
157
  ### Reserved namespace names
158
158
 
159
- The agent runtime injects a fixed set of globals into the JS REPL. These names cannot be used as `agentIdentity.namespace` values or as agent-function namespaces.
159
+ The agent runtime injects a fixed set of globals into the runtime session. These names cannot be used as `agentIdentity.namespace` values or as agent-function namespaces.
160
160
 
161
161
  ```text
162
162
  inputs
@@ -205,7 +205,7 @@ Rules:
205
205
 
206
206
  - Prefer namespaced functions.
207
207
  - Default function namespace is `utils` when no namespace is set.
208
- - Use the runtime call shape `await <namespace>.<name>({...})`.
208
+ - With `AxJSRuntime`, use the runtime call shape `await <namespace>.<name>({...})`. Custom runtimes should expose equivalent namespaced calls through their own `formatCallable()` guidance.
209
209
  - `.arg()` and `.returns()` can use Ax field helpers or any Standard Schema v1 validator directly.
210
210
 
211
211
  ## Grouped Function Modules
@@ -235,6 +235,26 @@ const parent = agent('query:string -> answer:string', {
235
235
  });
236
236
  ```
237
237
 
238
+ MCP clients and other `toFunction()` providers can be placed directly inside a group after initialization:
239
+
240
+ ```typescript
241
+ await mcpClient.init();
242
+
243
+ const parent = agent('query:string -> answer:string', {
244
+ functions: [
245
+ {
246
+ namespace: 'memory',
247
+ title: 'Memory MCP',
248
+ description: 'Memory server tools',
249
+ selectionCriteria: 'Use for persistent memory lookup and updates.',
250
+ functions: [mcpClient],
251
+ },
252
+ ],
253
+ functionDiscovery: true,
254
+ contextFields: [],
255
+ });
256
+ ```
257
+
238
258
  Rules:
239
259
 
240
260
  - A group is `{ namespace, title, description, functions: [...] }`.
@@ -242,8 +262,8 @@ Rules:
242
262
  - The group's `namespace`, `title`, `selectionCriteria`, and `description` show up in `discover(...)` module docs.
243
263
  - Add `alwaysInclude: true` to a group when discovery mode is on but the actor should always see that group's full callable definitions inline in the prompt.
244
264
  - Keep `functions: [...]` either flat or grouped. Runtime validation rejects mixed plain function entries and group objects.
245
- - In flat mode, pass `fn(...)` tools and child agents directly.
246
- - In grouped mode, put callable entries inside groups. To expose a child agent inside a group, use `childAgent.getFunction()`.
265
+ - In flat mode, pass `fn(...)` tools, child agents, and `toFunction()` providers directly.
266
+ - In grouped mode, put callable entries and `toFunction()` providers inside groups. To expose a child agent inside a group, use `childAgent.getFunction()`.
247
267
 
248
268
  ## Host-Side Completion From Functions
249
269
 
@@ -279,7 +299,7 @@ Rules:
279
299
 
280
300
  - `extra.protocol` is only available when the function call comes from an active AxAgent actor runtime session.
281
301
  - Use `extra.protocol.final(...)`, `extra.protocol.askClarification(...)`, or `extra.protocol.guideAgent(...)` only inside host-side function handlers.
282
- - Inside actor-authored JavaScript, use the runtime globals `final(...)` and `askClarification(...)`.
302
+ - Inside actor-authored runtime code, use the runtime globals `final(...)` and `askClarification(...)` with the syntax documented by the active runtime.
283
303
  - `extra.protocol.guideAgent(...)` is handler-only internal control flow. It stops the current actor turn and appends trusted guidance to `guidanceLog` for the next iteration.
284
304
  - `askClarification(...)` accepts either a simple string or a structured object with `question` plus optional UI hints such as `type: 'date' | 'number' | 'single_choice' | 'multiple_choice'` and `choices`.
285
305
 
package/skills/ax-ai.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: ax-ai
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/Groq/DeepSeek/Mistral/Cohere/Together/Ollama/HuggingFace/Reka/OpenRouter with @ax-llm/ax.
4
- version: "21.0.14"
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/HuggingFace/Reka/Grok with @ax-llm/ax.
4
+ version: "22.0.0"
5
5
  ---
6
6
 
7
7
  # AI Provider Codegen Rules (@ax-llm/ax)
@@ -17,16 +17,13 @@ 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
19
  const azure = ai({ name: 'azure-openai', apiKey: 'your-key', resourceName: 'your-resource', deploymentName: 'gpt-4' });
20
- const groq = ai({ name: 'groq', apiKey: 'gsk_...' });
21
20
  const deepseek = ai({ name: 'deepseek', apiKey: 'sk-...' });
22
21
  const mistral = ai({ name: 'mistral', apiKey: 'your-key' });
23
22
  const cohere = ai({ name: 'cohere', apiKey: 'your-key' });
24
- const together = ai({ name: 'together', apiKey: 'your-key' });
25
- const openrouter = ai({ name: 'openrouter', apiKey: 'your-key' });
26
- const ollama = ai({ name: 'ollama', url: 'http://localhost:11434' });
27
23
  const hf = ai({ name: 'huggingface', apiKey: 'hf_...' });
28
24
  const reka = ai({ name: 'reka', apiKey: 'your-key' });
29
25
  const grok = ai({ name: 'grok', apiKey: 'your-key' });
26
+ const compatible = ai({ name: 'openai', apiKey: 'key', apiURL: 'https://api.example.com/v1', config: { model: 'provider/model' } });
30
27
  ```
31
28
 
32
29
  ## Model Presets
@@ -64,7 +61,7 @@ Use `axGetSupportedAIModels()` to build provider/model selectors before creating
64
61
 
65
62
  Filter with `{ type: 'all' | 'text' | 'embeddings' | 'code' | 'audio' }` or an array of those values. The `'text'` filter includes code-capable models; use `'code'` to show only code-first models.
66
63
 
67
- Dynamic providers such as Azure OpenAI deployments, OpenRouter, Ollama, and Hugging Face are marked with `isDynamic: true` and may have an empty or static-limited model list.
64
+ Dynamic providers such as Azure OpenAI deployments and Hugging Face are marked with `isDynamic: true` and may have an empty or static-limited model list.
68
65
 
69
66
  ## Chat
70
67
 
@@ -165,7 +162,7 @@ import { ai, AxAIAnthropicModel } from '@ax-llm/ax';
165
162
  const claude = ai({
166
163
  name: 'anthropic',
167
164
  apiKey: process.env.ANTHROPIC_APIKEY!,
168
- config: { model: AxAIAnthropicModel.Claude46Opus },
165
+ config: { model: AxAIAnthropicModel.Claude48Opus },
169
166
  });
170
167
 
171
168
  const res = await claude.chat(
@@ -189,10 +186,27 @@ console.log(res.results[0]?.content);
189
186
 
190
187
  ### Anthropic Model-Specific Behavior
191
188
 
189
+ - Opus 4.8 and 4.7: adaptive thinking, effort levels including `'xhigh'`,
190
+ no manual `budget_tokens`, and no `temperature` / `topP` / `topK`.
192
191
  - Opus 4.6: adaptive thinking, effort levels
193
192
  - Opus 4.5: budget_tokens + effort levels (capped at `'high'`)
194
193
  - Other thinking models: budget tokens only
195
194
 
195
+ Anthropic `modelConfig.effort` can be set directly on a request. Fast mode and
196
+ task budgets are Anthropic-only opt-ins; `taskBudget.total` must be at least
197
+ 20,000 tokens.
198
+
199
+ ```typescript
200
+ const res = await claude.chat({
201
+ chatPrompt: [{ role: 'user', content: 'Review this migration plan.' }],
202
+ modelConfig: {
203
+ effort: 'xhigh',
204
+ speed: 'fast',
205
+ taskBudget: { type: 'tokens', total: 64_000 },
206
+ },
207
+ });
208
+ ```
209
+
196
210
  ### Custom Thinking Levels
197
211
 
198
212
  ```typescript
@@ -200,7 +214,7 @@ const claude = ai({
200
214
  name: 'anthropic',
201
215
  apiKey: '...',
202
216
  config: {
203
- model: AxAIAnthropicModel.Claude46Opus,
217
+ model: AxAIAnthropicModel.Claude48Opus,
204
218
  thinkingTokenBudgetLevels: {
205
219
  minimal: 2048,
206
220
  low: 8000,
@@ -300,8 +314,10 @@ const client = new AxMCPClient(transport);
300
314
  ## Critical Rules
301
315
 
302
316
  - Use `ai()` factory for all providers.
303
- - Provider names: `'openai'`, `'anthropic'`, `'google-gemini'`, `'azure-openai'`, `'mistral'`, `'groq'`, `'cohere'`, `'together'`, `'deepseek'`, `'ollama'`, `'huggingface'`, `'openrouter'`, `'reka'`, `'grok'`
304
- - Thinking constraints on Anthropic: `temperature` and `topK` are ignored; `topP` only sent if >= 0.95.
317
+ - Provider names: `'openai'`, `'openai-responses'`, `'anthropic'`, `'google-gemini'`, `'azure-openai'`, `'mistral'`, `'cohere'`, `'deepseek'`, `'huggingface'`, `'reka'`, `'grok'`
318
+ - Thinking constraints on Anthropic: Opus 4.8/4.7 omit `temperature`, `topP`,
319
+ and `topK`; older thinking models ignore `temperature` and `topK`, with
320
+ `topP` only sent if >= 0.95.
305
321
  - Bedrock uses `new AxAIBedrock()`, not `ai()`.
306
322
  - Vercel AI SDK uses `AxAIProvider` wrapper.
307
323
 
@@ -319,7 +335,7 @@ Fetch these for full working code:
319
335
  - [Gemini Context Cache](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/gemini-context-cache.ts) — Gemini context caching
320
336
  - [Gemini Files](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/gemini-file-support.ts) — Gemini file handling
321
337
  - [Grok Live Search](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/grok-live-search.ts) — Grok live search
322
- - [OpenRouter](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/openrouter.ts) — OpenRouter provider
338
+ - [OpenAI-Compatible](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/openai-compatible.ts) — custom OpenAI-compatible base URL
323
339
  - [Vertex AI Auth](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/vertex-auth-example.ts) — Vertex AI authentication
324
340
  - [MCP Stdio](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/mcp-client-memory.ts) — MCP stdio transport
325
341
  - [MCP HTTP](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/mcp-client-pipedream.ts) — MCP HTTP transport
@@ -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: "21.0.14"
4
+ version: "22.0.0"
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: "21.0.14"
4
+ version: "22.0.0"
5
5
  ---
6
6
 
7
7
  # AxFlow Codegen Rules (@ax-llm/ax)
@@ -12,7 +12,7 @@ Use this skill to generate `AxFlow` workflow code. Prefer short, modern, copyabl
12
12
 
13
13
  - Use `flow()` factory, not `new AxFlow()`.
14
14
  - Import: `import { ai, flow, f } from '@ax-llm/ax';`
15
- - `autoParallel: true` is the default; independent executes run in parallel automatically.
15
+ - `autoParallel: true` is the default; independent executes and derives run in parallel when their metadata reads/writes are known and non-conflicting.
16
16
  - Node results are stored as `${nodeName}Result` in state.
17
17
  - Always define `.node()` before `.execute()` for that node.
18
18
  - Use `.returns()` (or `.r()`) as the last step to lock the output type.
@@ -28,7 +28,7 @@ Use this skill to generate `AxFlow` workflow code. Prefer short, modern, copyabl
28
28
  - Always define nodes before executing them; reversed order throws at runtime.
29
29
  - Keep state flat; avoid deep nesting in `.map()`.
30
30
  - Ensure loop conditions can change to avoid infinite loops.
31
- - Structure independent executes to maximize auto-parallelization.
31
+ - Structure independent executes to maximize safe auto-parallelization.
32
32
  - Use `flow<InputType, OutputType>()` for typed flows.
33
33
  - Aliases: `.n()` = `.node()`, `.nx()` = `.nodeExtended()`, `.m()` = `.map()`, `.r()` = `.returns()`.
34
34
 
@@ -174,7 +174,7 @@ const wf = flow<{ input: string }, { finalResult: string }>()
174
174
 
175
175
  ## Auto-Parallel Execution
176
176
 
177
- Independent executes run in parallel automatically (`autoParallel: true` by default):
177
+ Independent execute steps run in parallel automatically (`autoParallel: true` by default) when their metadata reads/writes are known and non-conflicting:
178
178
 
179
179
  ```typescript
180
180
  const wf = flow<{ text: string }, { combined: string }>()
@@ -199,6 +199,12 @@ const plan = wf.getExecutionPlan();
199
199
  console.log(plan.parallelGroups, plan.maxParallelism);
200
200
  ```
201
201
 
202
+ Planner rules:
203
+ - Independent `.execute()` and `.derive()` steps may parallelize.
204
+ - `.map()`, `.returns()`, `.branch()`, `.while()`, `.feedback()`, and explicit `.parallel()` are barriers.
205
+ - Branch, while, and feedback bodies still use the same planner internally.
206
+ - Use `autoParallel: false` when you need strict sequential execution.
207
+
202
208
  Disable auto-parallel:
203
209
 
204
210
  ```typescript
@@ -299,7 +305,7 @@ const wf = flow<{ items: string[] }, { processed: string[] }>({ batchSize: 3 })
299
305
  Route nodes to different AI providers:
300
306
 
301
307
  ```typescript
302
- const fast = ai({ name: 'groq', apiKey: '...' });
308
+ const fast = ai({ name: 'openai', apiKey: '...', config: { model: 'gpt-5-mini' } });
303
309
  const smart = ai({ name: 'anthropic', apiKey: '...' });
304
310
 
305
311
  const wf = flow<{ text: string }, { out: string }>()
@@ -425,6 +431,8 @@ Fetch these for full working code:
425
431
 
426
432
  - Do not use `new AxFlow(...)` for new code.
427
433
  - Do not execute a node before defining it with `.node()`.
434
+ - Do not use removed terminal shapers like `.mapOutput()` or `.mo()`.
435
+ - Do not rely on broad signature inference from arbitrary transform source. Use explicit input/output generics and `.returns()` for the final output contract.
428
436
  - Do not use generic field names like `text`, `result`, `data`, `input`, `output`.
429
437
  - Do not create deep-nested state objects in `.map()`.
430
438
  - Do not create loop conditions that can never change.
package/skills/ax-gen.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: ax-gen
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(), assertions, field processors, step hooks, self-tuning, or structured outputs.
4
- version: "21.0.14"
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, streaming guards, field processors, step hooks, self-tuning, or structured outputs.
4
+ version: "22.0.0"
5
5
  ---
6
6
 
7
7
  # AxGen Codegen Rules (@ax-llm/ax)
@@ -13,7 +13,9 @@ Use this skill to generate `AxGen` code. Prefer short, modern, copyable patterns
13
13
  - Use `ax(...)` factory, not `new AxGen(...)`.
14
14
  - Always pass an AI instance from `ai(...)` as the first argument to `forward()`.
15
15
  - Streaming uses `streamingForward()`, not `forward()` with a stream option.
16
- - Assertions auto-retry with error feedback on failure.
16
+ - Use schema validation for field shape and constraints.
17
+ - Use `bestOfN(...)` / `refine(...)` for reward-scored complete outputs.
18
+ - Streaming guards abort unsafe partial output; they do not retry or refine.
17
19
  - Step hook mutations are applied at the next step boundary (pending pattern).
18
20
  - `stopFunction` accepts a string or string[] for multiple stop functions.
19
21
  - Multi-step continues until: all outputs filled, stop function called, or `maxSteps` reached.
@@ -173,18 +175,29 @@ Rules:
173
175
  - `abortSignal` cancels the underlying AI service call immediately.
174
176
  - Catch `AxAIServiceAbortedError` when using either mechanism.
175
177
 
176
- ## Assertions And Validation
178
+ ## Validation, Selection, And Guards
177
179
 
178
180
  ```typescript
179
- // Standard assertion (checked after forward completes)
180
- gen.addAssert(
181
- (args) => args.output.length > 50,
182
- 'Output must be at least 50 characters'
181
+ import { ax, bestOfN, f } from '@ax-llm/ax';
182
+ import { z } from 'zod';
183
+
184
+ // Schema validation: output shape and field validity.
185
+ const gen = ax(
186
+ f()
187
+ .input('topic', z.string().min(1))
188
+ .output('summary', z.string().min(50))
189
+ .build()
183
190
  );
184
191
 
185
- // Streaming assertion (checked during streaming)
186
- gen.addStreamingAssert(
187
- 'output',
192
+ // bestOfN: choose the best complete candidate.
193
+ const selected = bestOfN(gen, {
194
+ n: 4,
195
+ rewardFn: ({ prediction }) => prediction.summary.length,
196
+ });
197
+
198
+ // Streaming guards: fail fast on unsafe partial output.
199
+ gen.addStreamingGuard(
200
+ 'summary',
188
201
  (text) => !text.includes('forbidden'),
189
202
  'Output contains forbidden text'
190
203
  );
@@ -192,9 +205,12 @@ gen.addStreamingAssert(
192
205
 
193
206
  Rules:
194
207
 
195
- - Failed assertions cause an automatic retry with the error message fed back to the LLM.
196
- - `addAssert` receives the full output object.
197
- - `addStreamingAssert` targets a specific field and receives the partial text so far.
208
+ - Schema validation retries with parser/constraint feedback.
209
+ - `bestOfN(...)` scores complete candidates and returns the highest reward or first threshold hit.
210
+ - `refine(...)` runs rounds and can feed reward-derived advice into instruction components between rounds.
211
+ - `addStreamingGuard(...)` targets a string/code output field and receives partial text so far.
212
+ - Streaming guards only abort the stream by throwing `AxStreamingGuardError`.
213
+ - Breaking migration: do not generate removed `addAssert(...)` or `addStreamingAssert(...)` APIs.
198
214
 
199
215
  ## Field Processors
200
216
 
@@ -452,9 +468,10 @@ gen.resetUsage();
452
468
 
453
469
  Fetch these for full working code:
454
470
 
455
- - [Streaming](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/streaming.ts) — streaming with assertions
456
- - [Assertions](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/asserts.ts) — output validation
457
- - [Streaming Assertions](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/streaming-asserts.ts) — streaming with assertion checks
471
+ - [Streaming](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/streaming.ts) — field-by-field streaming
472
+ - [Best Of N](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/best-of-n.ts) — reward-scored sample selection
473
+ - [Refine](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/refine.ts) — retry rounds with generated feedback
474
+ - [Streaming Guard](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/streaming-guard.ts) — fail-fast partial-output safety
458
475
  - [Structured Output](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/structured_output.ts) — fluent API with validation
459
476
  - [Debug Logging](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/debug-logging.ts) — debug mode and step hooks
460
477
  - [Stop Function](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/stop-function.ts) — stop functions
@@ -467,6 +484,6 @@ Fetch these for full working code:
467
484
  - Do not use `new AxGen(...)` for new code unless explicitly required.
468
485
  - Do not pass raw API keys or config objects where an `ai(...)` instance is expected.
469
486
  - Do not use `forward()` for streaming; use `streamingForward()`.
470
- - Do not forget that assertions auto-retry; avoid manual retry loops around assertion logic.
487
+ - Do not use streaming guards as retry/refine mechanisms; they only abort unsafe partial output.
471
488
  - Do not mutate step hook context expecting immediate effect; mutations are pending until the next step.
472
489
  - Do not assume multi-step stops after one LLM call; it continues until outputs are filled, a stop function fires, or `maxSteps` is reached.
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: "21.0.14"
4
+ version: "22.0.0"
5
5
  ---
6
6
 
7
7
  # AxGEPA Codegen Rules (@ax-llm/ax)
package/skills/ax-llm.md CHANGED
@@ -1,20 +1,20 @@
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: "21.0.14"
4
+ version: "22.0.0"
5
5
  ---
6
6
 
7
7
  # Ax Library (@ax-llm/ax) Quick Reference
8
8
 
9
9
  Ax is a TypeScript library for building LLM-powered applications with type-safe signatures, streaming support, and multi-provider compatibility.
10
10
 
11
- > **Detailed skills available:** ax-ai (providers), ax-signature (signatures/types), ax-gen (generators), ax-agent (core agents/tools), ax-agent-rlm (agent runtime/RLM/delegation), ax-agent-observability (callbacks/logs/usage), ax-agent-memory-skills (recall and dynamic skill loading), ax-agent-optimize (agent tuning/eval), ax-flow (workflows), ax-gepa (Pareto optimization), ax-learn (self-improving agents).
11
+ > **Detailed skills available:** ax-ai (providers), ax-signature (signatures/types), ax-gen (generators), ax-agent (core agents/tools), ax-agent-rlm (agent runtime/RLM/delegation), ax-agent-observability (callbacks/logs/usage), ax-agent-memory-skills (recall and dynamic skill loading), ax-agent-optimize (agent tuning/eval), ax-flow (workflows), ax-gepa (Pareto optimization).
12
12
 
13
13
  ## Imports & Factories
14
14
 
15
15
  ```typescript
16
16
  // Prefer factory functions: ax(), ai(), agent(), flow() — not new AxGen(), new AxAI(), etc.
17
- import { ax, ai, f, s, fn, agent, flow, AxMemory, AxMCPClient, AxLearn } from '@ax-llm/ax';
17
+ import { ax, ai, f, s, fn, agent, flow, AxMemory, AxMCPClient } from '@ax-llm/ax';
18
18
  import { z } from 'zod'; // optional — any Standard Schema v1 library works
19
19
 
20
20
  // AI provider
@@ -239,7 +239,7 @@ axGlobals.meter = openTelemetryMeter;
239
239
  ## MCP Integration
240
240
 
241
241
  ```typescript
242
- import { AxMCPClient } from '@ax-llm/ax';
242
+ import { AxMCPClient, agent } from '@ax-llm/ax';
243
243
  import { AxMCPStdioTransport } from '@ax-llm/ax-tools';
244
244
 
245
245
  // Stdio transport (local MCP server)
@@ -251,11 +251,19 @@ const transport = new AxMCPStdioTransport({
251
251
  const mcpClient = new AxMCPClient(transport, { debug: false });
252
252
  await mcpClient.init();
253
253
 
254
- // Use with agent
254
+ // Use with agent under a namespace
255
255
  const myAgent = agent('userMessage:string -> response:string', {
256
- name: 'assistant',
257
- description: 'An assistant with MCP tools',
258
- functions: [mcpClient],
256
+ functions: [
257
+ {
258
+ namespace: 'memory',
259
+ title: 'Memory MCP',
260
+ description: 'Memory server tools',
261
+ selectionCriteria: 'Use for persistent memory lookup and updates.',
262
+ functions: [mcpClient],
263
+ },
264
+ ],
265
+ functionDiscovery: true,
266
+ contextFields: [],
259
267
  });
260
268
  ```
261
269
 
@@ -300,7 +308,7 @@ class AxGen<IN, OUT> {
300
308
  forward(ai: AxAIService, values: IN, options?: AxProgramForwardOptions): Promise<OUT>;
301
309
  streamingForward(ai: AxAIService, values: IN, options?: AxProgramStreamingForwardOptions): AsyncGenerator<{ delta: Partial<OUT> }>;
302
310
  setExamples(examples: Array<Partial<IN & OUT>>): void;
303
- addAssert(fn: (output: OUT) => boolean, message?: string): void;
311
+ addStreamingGuard(field: keyof OUT, fn: (chunk: string, done?: boolean) => boolean | string | undefined, message?: string): void;
304
312
  addFieldProcessor(field: keyof OUT, fn: (value: any) => any): void;
305
313
  addStreamingFieldProcessor(field: keyof OUT, fn: (chunk: string, ctx: any) => void): void;
306
314
  stop(): void;