@ax-llm/ax 22.0.1 → 22.0.2

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": "22.0.1",
3
+ "version": "22.0.2",
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: "22.0.1"
4
+ version: "22.0.2"
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.1"
4
+ version: "22.0.2"
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.1"
4
+ version: "22.0.2"
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: "22.0.1"
4
+ version: "22.0.2"
5
5
  ---
6
6
 
7
7
  # AxAgent RLM Runtime Rules (@ax-llm/ax)
@@ -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.1"
4
+ version: "22.0.2"
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/HuggingFace/Reka/Grok with @ax-llm/ax.
4
- version: "22.0.1"
4
+ version: "22.0.2"
5
5
  ---
6
6
 
7
7
  # AI Provider Codegen Rules (@ax-llm/ax)
@@ -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.1"
4
+ version: "22.0.2"
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.1"
4
+ version: "22.0.2"
5
5
  ---
6
6
 
7
7
  # AxFlow Codegen Rules (@ax-llm/ax)
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(), validation, streaming guards, field processors, step hooks, self-tuning, or structured outputs.
4
- version: "22.0.1"
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.2"
5
5
  ---
6
6
 
7
7
  # AxGen Codegen Rules (@ax-llm/ax)
@@ -14,8 +14,9 @@ Use this skill to generate `AxGen` code. Prefer short, modern, copyable patterns
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
16
  - Use schema validation for field shape and constraints.
17
+ - Use `addAssert(...)` for whole-output hard invariants with correction retries.
18
+ - Use `addStreamingAssert(...)` for partial streaming hard invariants with fail-fast per-attempt correction retries.
17
19
  - Use `bestOfN(...)` / `refine(...)` for reward-scored complete outputs.
18
- - Streaming guards abort unsafe partial output; they do not retry or refine.
19
20
  - Step hook mutations are applied at the next step boundary (pending pattern).
20
21
  - `stopFunction` accepts a string or string[] for multiple stop functions.
21
22
  - Multi-step continues until: all outputs filled, stop function called, or `maxSteps` reached.
@@ -195,8 +196,13 @@ const selected = bestOfN(gen, {
195
196
  rewardFn: ({ prediction }) => prediction.summary.length,
196
197
  });
197
198
 
198
- // Streaming guards: fail fast on unsafe partial output.
199
- gen.addStreamingGuard(
199
+ // Whole-output assertion: retries with correction feedback.
200
+ gen.addAssert(
201
+ (output) => output.summary.includes(topic) || 'Summary must mention the topic.'
202
+ );
203
+
204
+ // Streaming assertion: fail fast on unsafe partial output.
205
+ gen.addStreamingAssert(
200
206
  'summary',
201
207
  (text) => !text.includes('forbidden'),
202
208
  'Output contains forbidden text'
@@ -206,11 +212,11 @@ gen.addStreamingGuard(
206
212
  Rules:
207
213
 
208
214
  - Schema validation retries with parser/constraint feedback.
215
+ - `addAssert(...)` checks the complete parsed output after validation/processors and retries with correction feedback on failure.
209
216
  - `bestOfN(...)` scores complete candidates and returns the highest reward or first threshold hit.
210
217
  - `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.
218
+ - `addStreamingAssert(...)` targets a string/code output field and receives partial text so far.
219
+ - Streaming assertions abort the current stream attempt by throwing `AxStreamingAssertionError`, then feed correction feedback into AxGen retries.
214
220
 
215
221
  ## Field Processors
216
222
 
@@ -471,7 +477,7 @@ Fetch these for full working code:
471
477
  - [Streaming](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/streaming.ts) — field-by-field streaming
472
478
  - [Best Of N](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/best-of-n.ts) — reward-scored sample selection
473
479
  - [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
480
+ - [Streaming Assert](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/streaming-asserts.ts) — fail-fast partial-output correction
475
481
  - [Structured Output](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/structured_output.ts) — fluent API with validation
476
482
  - [Debug Logging](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/debug-logging.ts) — debug mode and step hooks
477
483
  - [Stop Function](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/stop-function.ts) — stop functions
@@ -484,6 +490,6 @@ Fetch these for full working code:
484
490
  - Do not use `new AxGen(...)` for new code unless explicitly required.
485
491
  - Do not pass raw API keys or config objects where an `ai(...)` instance is expected.
486
492
  - Do not use `forward()` for streaming; use `streamingForward()`.
487
- - Do not use streaming guards as retry/refine mechanisms; they only abort unsafe partial output.
493
+ - Do not use streaming assertions as reward/refine mechanisms; they enforce hard partial-output invariants and retry with correction.
488
494
  - Do not mutate step hook context expecting immediate effect; mutations are pending until the next step.
489
495
  - 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: "22.0.1"
4
+ version: "22.0.2"
5
5
  ---
6
6
 
7
7
  # AxGEPA Codegen Rules (@ax-llm/ax)
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.1"
4
+ version: "22.0.2"
5
5
  ---
6
6
 
7
7
  # Ax Library (@ax-llm/ax) Quick Reference
@@ -308,7 +308,8 @@ class AxGen<IN, OUT> {
308
308
  forward(ai: AxAIService, values: IN, options?: AxProgramForwardOptions): Promise<OUT>;
309
309
  streamingForward(ai: AxAIService, values: IN, options?: AxProgramStreamingForwardOptions): AsyncGenerator<{ delta: Partial<OUT> }>;
310
310
  setExamples(examples: Array<Partial<IN & OUT>>): void;
311
- addStreamingGuard(field: keyof OUT, fn: (chunk: string, done?: boolean) => boolean | string | undefined, message?: string): void;
311
+ addAssert(fn: (output: OUT) => boolean | string | undefined | Promise<boolean | string | undefined>, message?: string): void;
312
+ addStreamingAssert(field: keyof OUT, fn: (chunk: string, done?: boolean) => boolean | string | undefined | Promise<boolean | string | undefined>, message?: string): void;
312
313
  addFieldProcessor(field: keyof OUT, fn: (value: any) => any): void;
313
314
  addStreamingFieldProcessor(field: keyof OUT, fn: (chunk: string, ctx: any) => void): void;
314
315
  stop(): void;
@@ -1,22 +1,22 @@
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.1"
4
+ version: "22.0.2"
5
5
  ---
6
6
 
7
7
  # Ax Refine And BestOfN
8
8
 
9
9
  Use `bestOfN(...)` when you can score complete outputs independently. Use `refine(...)` when failed rounds should produce feedback that changes the next attempt.
10
10
 
11
- ## Breaking Migration
11
+ ## Validation And Assertions
12
12
 
13
- Treat this as a breaking API change:
13
+ Keep reward scoring, whole-output assertions, and streaming assertions separate:
14
14
 
15
- - Do not generate `addAssert(...)` or `addStreamingAssert(...)`; they are removed.
16
- - Use schema validation for shape and field validity.
15
+ - Use schema validation for shape, types, and field-level constraints.
16
+ - Use `addAssert(...)` for whole-output hard invariants. Failed assertions feed correction text into the normal retry loop.
17
+ - Use `addStreamingAssert(...)` for partial streaming hard invariants. It aborts the current stream attempt as soon as the partial field fails, then feeds correction text into the normal retry loop.
17
18
  - Use `bestOfN(...)` for complete-candidate selection.
18
- - Use `refine(...)` for retry rounds with generated feedback.
19
- - Use `addStreamingGuard(...)` only for fail-fast streaming safety.
19
+ - Use `refine(...)` for reward-scored retry rounds with generated feedback.
20
20
 
21
21
  ## APIs
22
22
 
@@ -78,4 +78,4 @@ Rules:
78
78
 
79
79
  ## Streaming
80
80
 
81
- Do not use `refine(...)` for streaming. For partial-output safety, use `addStreamingGuard(fieldName, fn, message?)` on `AxGen`. Guards fail fast with `AxStreamingGuardError`; they do not retry, refine, or feed correction text back to the model.
81
+ Do not use `refine(...)` for streaming. For partial-output safety, use `addStreamingAssert(fieldName, fn, message?)` on `AxGen`. Streaming assertions fail fast within the current attempt with `AxStreamingAssertionError`, then retry with correction feedback when retries remain.
@@ -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.1"
4
+ version: "22.0.2"
5
5
  ---
6
6
 
7
7
  # Ax Signature Reference