@ax-llm/ax 19.0.22 → 19.0.23

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": "19.0.22",
3
+ "version": "19.0.23",
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-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 recursive optimization guidance.
4
- version: "19.0.22"
4
+ version: "19.0.23"
5
5
  ---
6
6
 
7
7
  # AxAgent Optimize Codegen 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 AxAgent code using @ax-llm/ax. Use when the user asks about agent(), child agents, namespaced functions, discovery mode, shared fields, llmQuery(...), RLM code execution, promptLevel, recursionOptions, or agent runtime behavior. For tuning and eval with agent.optimize(...), use ax-agent-optimize.
4
- version: "19.0.22"
4
+ version: "19.0.23"
5
5
  ---
6
6
 
7
7
  # AxAgent Codegen Rules (@ax-llm/ax)
@@ -27,7 +27,7 @@ Your job is not just to write valid code. Your job is to choose the smallest cor
27
27
  - For long RLM tasks, prefer `contextPolicy: { preset: 'adaptive' }` so older successful turns collapse into checkpoint summaries while live runtime state stays visible.
28
28
  - Prefer `contextPolicy: { preset: 'checkpointed' }` when you want debugging-friendly full replay first and only want summaries after prompt pressure becomes real.
29
29
  - Default top-level `promptLevel` to `'detailed'` and opt down to `'basic'` only when the user wants a shorter root actor prompt.
30
- - Prefer `actorModelPolicy` when the actor may need to upgrade under prompt pressure, repeated tool errors, or discovery churn without also upgrading the responder.
30
+ - Prefer `actorModelPolicy` when the actor may need to upgrade under whole-prompt pressure or repeated error turns without also upgrading the responder.
31
31
  - Use `actorTurnCallback` when the user needs per-turn observability into generated code, raw runtime result, formatted output, or provider thoughts.
32
32
 
33
33
  ## Decision Guide
@@ -66,7 +66,7 @@ Use these meanings consistently when writing or explaining `contextPolicy.preset
66
66
 
67
67
  - `full`: Keep prior actions fully replayed. Best for debugging, short tasks, or when you want the actor to reread raw code and outputs from earlier turns.
68
68
  - `adaptive`: Keep runtime state visible, keep recent or dependency-relevant actions in full, and collapse older successful work into a `Checkpoint Summary` when context grows. This is the default recommendation for long multi-turn tasks.
69
- - `checkpointed`: Keep full replay until the action log crosses the checkpoint threshold, then replace older successful history with a `Checkpoint Summary` while keeping recent actions and unresolved errors fully visible.
69
+ - `checkpointed`: Keep full replay until the rendered actor prompt crosses the checkpoint threshold, then replace older successful history with a `Checkpoint Summary` while keeping recent actions and unresolved errors fully visible.
70
70
  - `lean`: Most aggressive compression. Keep `Live Runtime State`, checkpoint older successful work, and summarize replay-pruned successful turns instead of showing their full code blocks. Use when token pressure matters more than raw replay detail.
71
71
 
72
72
  Practical rule:
@@ -91,7 +91,7 @@ Treat these knobs as a bundle:
91
91
  - `contextPolicy.preset` decides how much raw history the actor keeps seeing.
92
92
  - Top-level `promptLevel` decides how prescriptive the root actor prompt is.
93
93
  - `recursionOptions.promptLevel` overrides prompt detail for recursive `llmQuery(...)` child agents.
94
- - `actorModelPolicy` decides when the actor upgrades to a stronger model without changing the responder.
94
+ - `actorModelPolicy` decides when the actor switches to an override model without changing the responder.
95
95
  - Model size decides how well the actor can recover from compressed context and terse guidance.
96
96
 
97
97
  Recommended combinations:
@@ -609,18 +609,18 @@ Rules:
609
609
 
610
610
  - Use `preset: 'full'` when the actor should keep seeing raw prior code and outputs with minimal compression.
611
611
  - Use `preset: 'adaptive'` when the task needs runtime state across many turns but older successful work should collapse into checkpoint summaries while important recent steps can still stay fully replayed.
612
- - Use `preset: 'checkpointed'` when you want full replay first, then only older successful history checkpointed after the log crosses `checkpoints.triggerChars`.
612
+ - Use `preset: 'checkpointed'` when you want full replay first, then only older successful history checkpointed after the rendered actor prompt crosses `checkpoints.triggerChars`.
613
613
  - Use `preset: 'lean'` when you want more aggressive compression and can rely mostly on current runtime state plus checkpoint summaries and compact action summaries.
614
614
  - `adaptive` now keeps used discovery docs by default and uses slightly richer live-state/checkpoint settings than `lean`; it should be the first choice unless you have a strong reason to prefer `full` or `lean`.
615
615
  - `checkpointed` keeps the most recent `3` actions in full and keeps unresolved errors fully replayed even after checkpointing starts.
616
616
  - Use `state.summary` to inject a compact `Live Runtime State` block into the actor prompt. The block is structured and provenance-aware: variables are rendered with compact type/size/preview metadata, and when Ax can infer it, a short source suffix like `from t3 via db.search` is included. Combine `maxEntries` with `maxChars` so large runtime objects do not dominate the prompt.
617
- - Use `state.inspect` with `inspectThresholdChars` so the actor is reminded to call `inspect_runtime()` when replayed action history starts getting large.
617
+ - Use `state.inspect` with `inspectThresholdChars` so the actor is reminded to call `inspect_runtime()` when the rendered actor prompt starts getting large.
618
618
  - `adaptive` keeps used discovery docs by default; set `contextPolicy.pruneUsedDocs: true` only when you want more aggressive cleanup.
619
619
  - `checkpointed` keeps used discovery docs by default; set `contextPolicy.pruneUsedDocs: true` only when you want the same cleanup there.
620
620
  - `lean` hides used discovery docs by default; set `contextPolicy.pruneUsedDocs: false` if you want to keep replaying them.
621
621
  - `full` keeps used discovery docs by default; set `contextPolicy.pruneUsedDocs: true` if you want the same cleanup there.
622
622
  - `checkpointed` uses a checkpoint summarizer that is optimized to preserve exact callables, ids, enum literals, date/time strings, query formats, and failures worth avoiding. Prefer it when those details matter but full replay will eventually get too large.
623
- - Lower `checkpoints.triggerChars` when you want checkpointing to begin sooner; raise it when you want longer raw replay before summarization starts.
623
+ - Lower `checkpoints.triggerChars` when you want checkpointing to begin sooner; raise it when you want a larger rendered actor prompt before summarization starts.
624
624
  - Use `summarizerOptions` to tune the internal checkpoint-summary AxGen program.
625
625
  - If you configure `expert.tombstones`, treat the object form as options for the internal tombstone-summary AxGen program.
626
626
  - Internal checkpoint and tombstone summarizers are stateless helpers: `functions` are not allowed, `maxSteps` is forced to `1`, and `mem` is not propagated.
@@ -708,7 +708,7 @@ Use these top-level controls consistently:
708
708
  - `recursionOptions.promptLevel`: overrides prompt guidance for recursive `llmQuery(...)` child agents
709
709
  - `maxSubAgentCalls`: shared delegated-call budget across the whole run, including recursive children
710
710
  - `actorOptions`: actor-only forward options such as `description`, `model`, `modelConfig`, `thinkingTokenBudget`, and `showThoughts`
711
- - `actorModelPolicy`: actor-only model escalation rules based on prompt-facing size, recent errors, and discovery stall turns
711
+ - `actorModelPolicy`: actor-only model override rules based on full rendered prompt size or consecutive error turns
712
712
  - `responderOptions`: responder-only forward options
713
713
  - `judgeOptions`: built-in judge options for `agent.optimize(...)`; for tuning workflows use the `ax-agent-optimize` skill
714
714
 
@@ -731,11 +731,13 @@ const researchAgent = agent('query:string -> answer:string', {
731
731
  description: 'Use tools first and keep JS steps small.',
732
732
  model: 'gpt-5.4-mini',
733
733
  },
734
- actorModelPolicy: {
735
- escalatedModel: 'gpt-5.4',
736
- escalateAtPromptChars: 14_000,
737
- escalateAtPromptCharsWhenCheckpointed: 10_000,
738
- },
734
+ actorModelPolicy: [
735
+ {
736
+ model: 'gpt-5.4',
737
+ abovePromptChars: 16_000,
738
+ aboveErrorTurns: 2,
739
+ },
740
+ ],
739
741
  responderOptions: {
740
742
  model: 'gpt-5.4-mini',
741
743
  },
@@ -748,9 +750,11 @@ Semantics:
748
750
  - `recursionOptions.promptLevel` applies only to recursive `llmQuery(...)` child agents in advanced mode.
749
751
  - If `recursionOptions.promptLevel` is omitted, recursive children inherit the root top-level `promptLevel`.
750
752
  - `mode` stays top-level; there is no `recursionOptions.mode`.
751
- - If `actorModelPolicy.baseModel` is omitted, Ax uses the current actor model as the base model.
753
+ - The current merged actor model stays the default base model. `actorModelPolicy` only overrides it when a rule matches.
752
754
  - `actorModelPolicy` only switches the actor model. It does not change `responderOptions.model`.
753
- - Recursive child agents can inherit `actorModelPolicy`; use a child override only when that child needs different escalation behavior.
755
+ - Recursive child agents can inherit `actorModelPolicy`; use a child override only when that child needs different routing behavior.
756
+ - `actorModelPolicy` entries are ordered from weaker to stronger. If multiple rules match, the last matching entry wins.
757
+ - If one entry defines both `abovePromptChars` and `aboveErrorTurns`, it matches when either threshold is crossed.
754
758
 
755
759
  When choosing these options for a user:
756
760
 
@@ -770,7 +774,7 @@ Key fields:
770
774
  - `recursionOptions.promptLevel`: choose `'basic'` or `'detailed'` guidance for recursive child agents
771
775
  - `actorOptions.description`: append extra actor-specific instructions without changing the responder prompt
772
776
  - `actorOptions.model` / `responderOptions.model`: split model choice across actor and responder when needed
773
- - `actorModelPolicy`: auto-upgrade only the actor when prompt-facing context, recent errors, or discovery churn indicate the current actor model is struggling
777
+ - `actorModelPolicy`: auto-switch only the actor when the rendered actor prompt is large or the run is on a consecutive error streak
774
778
 
775
779
  Good split-model pattern:
776
780
 
@@ -795,7 +799,7 @@ Model guidance:
795
799
  - Put the stronger model on the responder only when the hard part is final synthesis/formatting rather than exploration.
796
800
  - For cost-sensitive setups, a common pattern is stronger actor + cheaper responder, not the other way around.
797
801
  - Prefer `actorModelPolicy` over globally upgrading the whole agent when the actor only needs help after context grows or the run starts thrashing.
798
- - `actorModelPolicy` uses prompt-facing pressure, not raw `actionLog.length`. That pressure includes replayed actions, live runtime state, delegated context summaries, context metadata, and actor-definition size.
802
+ - `actorModelPolicy` uses full rendered actor prompt chars, not raw `actionLog.length`. That prompt includes the actor definition, user inputs, context metadata, replayed actions, live runtime state, delegated context summaries, and checkpoint summaries.
799
803
  - Pair `contextPolicy: { preset: 'checkpointed' }` with `actorModelPolicy` when you want "full first, then summarize and upgrade the actor only if needed."
800
804
 
801
805
  Invalid pattern:
@@ -1051,18 +1055,30 @@ agentIdentity?: {
1051
1055
  inputUpdateCallback?: (currentInputs: Record<string, unknown>) => Promise<Record<string, unknown> | undefined> | Record<string, unknown> | undefined;
1052
1056
  mode?: 'simple' | 'advanced';
1053
1057
  promptLevel?: 'detailed' | 'basic';
1054
- actorModelPolicy?: {
1055
- escalatedModel: string;
1056
- baseModel?: string;
1057
- escalateAtPromptChars?: number;
1058
- escalateAtPromptCharsWhenCheckpointed?: number;
1059
- recentErrorWindowTurns?: number;
1060
- recentErrorThreshold?: number;
1061
- discoveryStallTurns?: number;
1062
- deescalateBelowPromptChars?: number;
1063
- stableTurnsBeforeDeescalate?: number;
1064
- minEscalatedTurns?: number;
1065
- };
1058
+ actorModelPolicy?: readonly [
1059
+ | {
1060
+ model: string;
1061
+ abovePromptChars: number;
1062
+ aboveErrorTurns?: number;
1063
+ }
1064
+ | {
1065
+ model: string;
1066
+ abovePromptChars?: number;
1067
+ aboveErrorTurns: number;
1068
+ },
1069
+ ...Array<
1070
+ | {
1071
+ model: string;
1072
+ abovePromptChars: number;
1073
+ aboveErrorTurns?: number;
1074
+ }
1075
+ | {
1076
+ model: string;
1077
+ abovePromptChars?: number;
1078
+ aboveErrorTurns: number;
1079
+ }
1080
+ >,
1081
+ ];
1066
1082
  recursionOptions?: Partial<Omit<AxProgramForwardOptions, 'functions'>> & {
1067
1083
  maxDepth?: number;
1068
1084
  promptLevel?: 'detailed' | 'basic';
@@ -1076,6 +1092,8 @@ agentIdentity?: {
1076
1092
  - `actorTurnCallback` fires for the root agent and for recursive child agents that run actor turns.
1077
1093
  - `promptLevel` controls the root actor prompt.
1078
1094
  - `actorModelPolicy` applies to the actor loop and can be inherited by recursive child agents unless you override it there.
1095
+ - `abovePromptChars` is measured from the full rendered actor prompt, not just replayed action log text.
1096
+ - Consecutive error turns reset after a successful non-error turn and when checkpoint summarization refreshes to a new fingerprint.
1079
1097
  - `recursionOptions.promptLevel` controls recursive child prompt guidance and falls back to the top-level `promptLevel`.
1080
1098
  - `maxSubAgentCalls` is a shared delegated-call budget across the entire run.
1081
1099
 
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, 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: "19.0.22"
4
+ version: "19.0.23"
5
5
  ---
6
6
 
7
7
  # AI Provider 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: "19.0.22"
4
+ version: "19.0.23"
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
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: "19.0.22"
4
+ version: "19.0.23"
5
5
  ---
6
6
 
7
7
  # AxGen Codegen Rules (@ax-llm/ax)
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: "19.0.22"
4
+ version: "19.0.23"
5
5
  ---
6
6
 
7
7
  # AxGEPA Codegen Rules (@ax-llm/ax)
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: ax-learn
3
3
  description: This skill helps an LLM generate correct AxLearn code using @ax-llm/ax. Use when the user asks about self-improving agents, trace-backed learning, feedback-aware updates, or AxLearn modes.
4
- version: "19.0.22"
4
+ version: "19.0.23"
5
5
  ---
6
6
 
7
7
  # AxLearn Codegen Rules (@ax-llm/ax)
package/skills/ax-llm.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: ax
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: "19.0.22"
4
+ version: "19.0.23"
5
5
  ---
6
6
 
7
7
  # Ax Library (@ax-llm/ax) Quick Reference
@@ -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: "19.0.22"
4
+ version: "19.0.23"
5
5
  ---
6
6
 
7
7
  # Ax Signature Reference