@ax-llm/ax 22.0.8 → 23.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/index.cjs +463 -390
- package/index.cjs.map +1 -1
- package/index.d.cts +582 -9
- package/index.d.ts +582 -9
- package/index.global.js +463 -390
- package/index.global.js.map +1 -1
- package/index.js +463 -390
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/ax-agent-context.md +2 -1
- package/skills/ax-agent-memory-skills.md +107 -9
- package/skills/ax-agent-observability.md +5 -1
- package/skills/ax-agent-optimize.md +2 -1
- package/skills/ax-agent-rlm.md +14 -3
- package/skills/ax-agent.md +26 -1
- package/skills/ax-ai.md +1 -1
- package/skills/ax-audio.md +1 -1
- package/skills/ax-flow.md +1 -1
- package/skills/ax-gen.md +1 -1
- package/skills/ax-gepa.md +1 -1
- package/skills/ax-llm.md +1 -1
- package/skills/ax-playbook.md +1 -1
- package/skills/ax-refine.md +1 -1
- package/skills/ax-signature.md +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-agent-context
|
|
3
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: "
|
|
4
|
+
version: "23.0.0"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Context Selection (@ax-llm/ax)
|
|
@@ -25,6 +25,7 @@ Use this skill to route a context-management need to the right AxAgent tool, the
|
|
|
25
25
|
- Evolve a context playbook -> `agent.playbook(...)` (offline from examples, or online from live feedback).
|
|
26
26
|
- Tune instructions/demos offline -> `agent.optimize(...)` (GEPA).
|
|
27
27
|
- Fetch facts or guides on demand -> `recall(...)` for memories, `discover({ skills })` for skill guides.
|
|
28
|
+
- A single oversized input value (a pasted doc, a big JSON blob) -> do nothing; `autoUpgrade` (ON by default) keeps it runtime-only with a prompt preview. Reach for `contextFields` only when you want a specific inline policy or the value is a large required non-string field. See `ax-agent-rlm`.
|
|
28
29
|
|
|
29
30
|
## Anti-Patterns
|
|
30
31
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-agent-memory-skills
|
|
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: "
|
|
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, memoriesCatalog, recall(...), inputs.memories, onLoadedMemories, onUsedMemories, onSkillsSearch, skillsCatalog, AxAgentCatalogSkill, discover({ skills }), onLoadedSkills, onUsedSkills, preloaded skills, preloading memories at forward time, relevanceRanking hints, loaded memory/skill IDs, or carrying memories across forward() calls.
|
|
4
|
+
version: "23.0.0"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Memory And Skills Rules (@ax-llm/ax)
|
|
@@ -10,11 +10,12 @@ Use this skill when an agent needs a persistent context map, task-relevant memor
|
|
|
10
10
|
|
|
11
11
|
## Use These Defaults
|
|
12
12
|
|
|
13
|
-
- Use `
|
|
13
|
+
- Use a static `skillsCatalog` / `memoriesCatalog` when the skill guides or memories fit in a plain array — Ax then backs `discover({ skills })` / `recall(...)` with a built-in deterministic local search and no host search code is needed.
|
|
14
|
+
- Use `onSkillsSearch` / `onMemoriesSearch` when retrieval needs a real backend (vector DB, BM25 service, KV). A host callback always takes precedence over the catalog's built-in search.
|
|
14
15
|
- Use `contextMap` when repeated runs inspect the same long external context and should accumulate a small orientation cache automatically.
|
|
15
|
-
-
|
|
16
|
-
- `
|
|
17
|
-
- `
|
|
16
|
+
- `recall(...)` is available to distiller and executor stages when `onMemoriesSearch` or a non-empty `memoriesCatalog` is set.
|
|
17
|
+
- `discover({ skills })` is available to the executor when `onSkillsSearch` or a non-empty `skillsCatalog` is set.
|
|
18
|
+
- With `skillsCatalog`, the executor prompt also gains a static `### Available Skills` index (id + name + description), so skill discovery is targeted instead of blind.
|
|
18
19
|
- Both `recall(...)` and `discover({ skills })` return `void`. The loaded content appears on the next turn.
|
|
19
20
|
- Use `onLoadedMemories` / `onLoadedSkills` to observe what got loaded.
|
|
20
21
|
- Use `onUsedMemories` / `onUsedSkills` to track what the actor says it actually relied on.
|
|
@@ -112,6 +113,37 @@ type AxAgentMemoryResult = {
|
|
|
112
113
|
};
|
|
113
114
|
```
|
|
114
115
|
|
|
116
|
+
### Static catalog (no callback)
|
|
117
|
+
|
|
118
|
+
If the memory set fits in a plain array, skip the callback entirely: pass `memoriesCatalog` and Ax backs `recall(...)` with a built-in deterministic local search (idf-weighted token overlap over `id` + content; not regex, not embeddings). The `alreadyLoaded` contract is preserved — entries already on `inputs.memories` are excluded before ranking.
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
const myAgent = agent('task:string -> answer:string', {
|
|
122
|
+
contextFields: [],
|
|
123
|
+
memoriesCatalog: [
|
|
124
|
+
{ id: 'deploy-window', content: 'Prod deploys only on Tuesday afternoons.' },
|
|
125
|
+
{ id: 'user-prefs', content: 'User prefers concise answers.' },
|
|
126
|
+
],
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Rules:
|
|
131
|
+
|
|
132
|
+
- If both `memoriesCatalog` and `onMemoriesSearch` are set, the host callback handles all `recall(...)` searches; the catalog still powers the advisory `relevanceRanking` hint.
|
|
133
|
+
- Catalog content is NOT preloaded into the prompt; entries load only when recalled.
|
|
134
|
+
- The built-in search is lexical. For semantic retrieval over large stores, supply `onMemoriesSearch` instead.
|
|
135
|
+
|
|
136
|
+
### Preloading memories at forward time
|
|
137
|
+
|
|
138
|
+
To seed specific memories for one run (no recall round-trip), pass them as the `memories` input value. They render on `inputs.memories` from the first turn and merge with anything recalled later (deduped by `id`).
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
await myAgent.forward(ai, {
|
|
142
|
+
task: 'Plan the deploy',
|
|
143
|
+
memories: [{ id: 'deploy-window', content: 'Prod deploys only on Tuesday afternoons.' }],
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
115
147
|
### Actor usage
|
|
116
148
|
|
|
117
149
|
```javascript
|
|
@@ -170,12 +202,12 @@ const myAgent = agent('task:string -> answer:string', {
|
|
|
170
202
|
|
|
171
203
|
Use `onSkillsSearch` when the agent needs to load skill guides such as usage instructions, runbooks, or domain conventions into the executor's system prompt on demand. The actor decides which skills to fetch and when, so you do not pre-render every skill into every prompt.
|
|
172
204
|
|
|
173
|
-
When `onSkillsSearch` is set, the executor
|
|
205
|
+
When `onSkillsSearch` is set, the distiller and executor stages gain:
|
|
174
206
|
|
|
175
207
|
1. A "Loaded Skills" section in the system prompt that renders matched skill bodies with stable `ID:` values sorted by `id`.
|
|
176
208
|
2. A `discover({ skills })` path the actor `await`s to load more skills. Loaded entries appear in the next turn's prompt. `discover(...)` returns nothing.
|
|
177
209
|
|
|
178
|
-
|
|
210
|
+
Skills the distiller loads carry over to the executor automatically. The responder does not see skills.
|
|
179
211
|
|
|
180
212
|
### Enabling
|
|
181
213
|
|
|
@@ -210,6 +242,43 @@ type AxAgentSkillResult = {
|
|
|
210
242
|
};
|
|
211
243
|
```
|
|
212
244
|
|
|
245
|
+
### Static catalog (no callback)
|
|
246
|
+
|
|
247
|
+
If the skill set fits in a plain array, skip the callback entirely: pass `skillsCatalog` and Ax backs `discover({ skills })` with a built-in deterministic local search (idf-weighted token overlap over `id` + `name`×2 + `description`×2 + the first 600 chars of `content`; not regex, not embeddings). The executor prompt also gains a static, cache-stable `### Available Skills` index (id + name + description, sorted by id), so the actor searches by known ids instead of guessing.
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
import type { AxAgentCatalogSkill } from '@ax-llm/ax';
|
|
251
|
+
|
|
252
|
+
const catalog: AxAgentCatalogSkill[] = [
|
|
253
|
+
{
|
|
254
|
+
id: 'release-checklist',
|
|
255
|
+
name: 'Release checklist',
|
|
256
|
+
description: 'Steps for shipping a package release safely', // high-signal for matching
|
|
257
|
+
content: '1. Bump version\n2. Run tests\n3. Tag and publish',
|
|
258
|
+
},
|
|
259
|
+
];
|
|
260
|
+
|
|
261
|
+
const myAgent = agent('task:string -> answer:string', {
|
|
262
|
+
contextFields: [],
|
|
263
|
+
skillsCatalog: catalog,
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
type AxAgentCatalogSkill = {
|
|
269
|
+
id: string;
|
|
270
|
+
name: string;
|
|
271
|
+
description?: string;
|
|
272
|
+
content: string;
|
|
273
|
+
};
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Rules:
|
|
277
|
+
|
|
278
|
+
- If both `skillsCatalog` and `onSkillsSearch` are set, the host callback handles all `discover({ skills })` searches; the catalog still powers the `### Available Skills` index and the advisory `relevanceRanking` hint.
|
|
279
|
+
- Catalog content is NOT preloaded into the prompt (unlike `skills`); entries load only when matched. Use `skills` for guides that must always be in context, `skillsCatalog` for a larger set loaded on demand.
|
|
280
|
+
- The built-in search is lexical. For semantic retrieval over large stores, supply `onSkillsSearch` instead.
|
|
281
|
+
|
|
213
282
|
### Actor usage
|
|
214
283
|
|
|
215
284
|
```javascript
|
|
@@ -270,6 +339,29 @@ await releaseAgent.forward(
|
|
|
270
339
|
|
|
271
340
|
You can use `skills` without setting `onSkillsSearch` at all. That is useful for static guides where the actor never needs to fetch more.
|
|
272
341
|
|
|
342
|
+
## Advisory Relevance Hints (`relevanceRanking`)
|
|
343
|
+
|
|
344
|
+
`relevanceRanking` is ON by default — leave it unset; set `relevanceRanking: false` to opt out. The default was flipped after its A/B gate passed (substance-judged, 49 runs per variant per model: small-model first-lookup precision 24%→90% and answer accuracy 14%→29%; frontier-model control accuracy 63%→88% with fewer turns). The generated language ports implement the same advisory hint contract through AxIR Core.
|
|
345
|
+
|
|
346
|
+
When enabled, a deterministic local ranker scores the agent's discoverable capabilities against the task once per `forward(...)` and injects a short advisory `### Likely Relevant` shortlist into the executor turn — modules (needs `functionDiscovery`), catalog skills (needs `skillsCatalog`), and catalog memories (needs `memoriesCatalog`). The hint is non-authoritative: the full lists still apply and the actor may `discover`/`recall` anything else.
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
const myAgent = agent('task:string -> answer:string', {
|
|
350
|
+
contextFields: [],
|
|
351
|
+
functionDiscovery: true,
|
|
352
|
+
skillsCatalog: catalog,
|
|
353
|
+
relevanceRanking: true, // or { topK: 3, minScore: 0.08 }
|
|
354
|
+
});
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
Rules:
|
|
358
|
+
|
|
359
|
+
- Default is ON across TypeScript and generated language ports; domains still self-gate on their prerequisites (`functionDiscovery` for modules, catalogs for skills/memories), so agents without those see no change. Everything else in this skill (catalog search, the Available Skills index) is independent of the flag.
|
|
360
|
+
- The shortlist rides a dynamic, non-cached prompt field; the cached system prompt stays byte-stable across tasks.
|
|
361
|
+
- On low confidence the ranker emits nothing rather than guessing.
|
|
362
|
+
- Memory hint entries include an ~80-char content snippet; very short memories may be usable from the hint alone without a `recall(...)` (such use is not visible to `onUsedMemories`).
|
|
363
|
+
- Observe outcomes via the `relevance_ranking` context event (see `ax-agent-observability`).
|
|
364
|
+
|
|
273
365
|
## Loaded And Used Tracking
|
|
274
366
|
|
|
275
367
|
`onLoadedMemories` reports what `recall(...)` loaded. `onLoadedSkills` reports what `discover({ skills })` loaded. To track what the actor says it actually relied on, use `onUsedMemories` / `onUsedSkills`.
|
|
@@ -318,6 +410,9 @@ onUsedSkills?: (
|
|
|
318
410
|
|
|
319
411
|
contextMap?: AxAgentContextMapConfig;
|
|
320
412
|
skills?: readonly AxAgentSkillResult[];
|
|
413
|
+
skillsCatalog?: readonly AxAgentCatalogSkill[];
|
|
414
|
+
memoriesCatalog?: readonly AxAgentMemoryResult[];
|
|
415
|
+
relevanceRanking?: boolean | { topK?: number; minScore?: number };
|
|
321
416
|
```
|
|
322
417
|
|
|
323
418
|
## Examples
|
|
@@ -331,10 +426,13 @@ Fetch this for full working code:
|
|
|
331
426
|
|
|
332
427
|
- Do not assign the result of `await recall(...)` or `await discover(...)`; both return `void`.
|
|
333
428
|
- Do not call `recall()` from the responder stage.
|
|
334
|
-
- Do not call `discover({ skills })` from the
|
|
429
|
+
- Do not call `discover({ skills })` from the responder stage.
|
|
335
430
|
- Do not loop `recall()` calls or wrap them in `Promise.all(...)`.
|
|
336
431
|
- Do not loop `discover()` calls or wrap them in `Promise.all(...)`.
|
|
337
432
|
- Do not assume child agents inherit `onMemoriesSearch` or `onSkillsSearch`.
|
|
338
433
|
- Do not pass `onMemoriesSearch` results via shared fields as a workaround; use `recall(...)`.
|
|
339
434
|
- Do not assume `inputs.memories` persists across `.forward()` calls.
|
|
340
435
|
- Do not use `onLoadedMemories` / `onLoadedSkills` as proof that the actor relied on an item; use `onUsedMemories` / `onUsedSkills` for actual-use tracking.
|
|
436
|
+
- Do not write an `onSkillsSearch` / `onMemoriesSearch` callback that just scans a static array; pass the array as `skillsCatalog` / `memoriesCatalog` instead.
|
|
437
|
+
- Do not rely on the built-in catalog search for semantic matching over large stores; it is lexical token overlap — supply a host callback for embeddings/vector search.
|
|
438
|
+
- Do not confuse `skills` (always preloaded into the prompt) with `skillsCatalog` (searchable, loaded on demand).
|
|
@@ -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: "
|
|
4
|
+
version: "23.0.0"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Observability Rules (@ax-llm/ax)
|
|
@@ -153,6 +153,10 @@ Events:
|
|
|
153
153
|
- `budget_check`: character-based prompt pressure before an actor turn, with detailed metrics kept out of the actor prompt
|
|
154
154
|
- `checkpoint_created` / `checkpoint_cleared`: checkpoint lifecycle events with covered turns and reason
|
|
155
155
|
- `tombstone_created`: compact resolved-error summary creation
|
|
156
|
+
- `relevance_ranking`: emitted once per ranked domain per forward when `relevanceRanking` is enabled; carries `domain` (`'modules' | 'skills' | 'memories'`), the `shortlist` (`{ id, score }[]`, most relevant first), and `suppressed` (true when the low-confidence guard emitted no hint)
|
|
157
|
+
- `field_auto_promoted`: emitted once per field per run when `autoUpgrade` keeps an oversized undeclared input value runtime-only; carries `fieldName`, `originalChars`, and `promptPreviewChars` (undefined when no inline preview was kept)
|
|
158
|
+
|
|
159
|
+
To measure whether the advisory hint helps, join per forward: `relevance_ranking.shortlist` ids against what the actor then loaded — for modules the internal `discover` calls (`onFunctionCall` with `kind: 'internal'`, `name: 'discover'`, `args.request`) plus the module part of external `qualifiedName`s; for skills `onLoadedSkills` / `used(id)`; for memories `onLoadedMemories` / `used(id)`.
|
|
156
160
|
|
|
157
161
|
Rules:
|
|
158
162
|
|
|
@@ -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: "
|
|
4
|
+
version: "23.0.0"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Optimize Codegen Rules (@ax-llm/ax)
|
|
@@ -30,6 +30,7 @@ Your job is to help the model choose a good optimization setup for the user's ac
|
|
|
30
30
|
- Save artifacts with `axSerializeOptimizedProgram(result.optimizedProgram!)`, then restore with `axDeserializeOptimizedProgram(saved)` and `agent.applyOptimization(...)`.
|
|
31
31
|
- For browser-safe persistence, let the caller store the serialized JSON anywhere they want such as localStorage, IndexedDB, or a backend.
|
|
32
32
|
- If `bootstrap` is enabled, bootstrapped demos are persisted inside `result.optimizedProgram.demos`; raw failed traces are not saved in v1.
|
|
33
|
+
- Auto-promoted context fields (large undeclared inputs kept runtime-only by `autoUpgrade`) appear in captured traces/demos as their truncated preview string, not the full value — same as declared truncate-style `contextFields`. This is expected; do not treat the shortened value as a bug in the saved demos.
|
|
33
34
|
- For first examples, pass a plain task array instead of splitting into `train` and `validation` unless the user already has a holdout set.
|
|
34
35
|
- GEPA-backed `agent.optimize(...)` now optimizes generic components exposed by the selected target programs; `target: 'actor'` only tunes actor components, `target: 'responder'` only tunes responder components, and `target: 'all'` broadens the component set.
|
|
35
36
|
- `result.optimizedProgram.componentMap` is the canonical saved artifact for agent GEPA runs. It may include actor instructions, descriptions, tool descriptions/names, templates, or runtime primitives depending on what the selected target exposes.
|
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: "
|
|
4
|
+
version: "23.0.0"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent RLM Runtime Rules (@ax-llm/ax)
|
|
@@ -12,6 +12,7 @@ Use this skill for code-runtime agents and `llmQuery(...)` semantic-helper behav
|
|
|
12
12
|
|
|
13
13
|
- Use `agent(...)`, not `new AxAgent(...)`.
|
|
14
14
|
- In stdout-mode RLM, use one observable `console.log(...)` step per non-final actor turn.
|
|
15
|
+
- Rely on `autoUpgrade` (ON by default) for oversized inputs you did not declare in `contextFields`: any input value over ~8k serialized chars is kept runtime-only automatically, with a 1,200-char prompt preview plus a `contextMetadata` line, while the full value stays live in the runtime as `inputs.<field>`. Declare a field in `contextFields` only when you want a specific inline policy (`promptMaxChars` / `keepInPromptChars`) or need a large required non-string field kept out of the prompt (those are left inline by auto-upgrade).
|
|
15
16
|
- Default to `contextPolicy: { preset: 'checkpointed', budget: 'balanced' }` for most RLM tasks.
|
|
16
17
|
- Prefer `contextPolicy: { preset: 'adaptive', budget: 'balanced' }` when older successful turns should collapse sooner while live runtime state stays visible.
|
|
17
18
|
- Use `contextMap` for recurring long-context corpora when the distiller should start future runs with a small persisted orientation cache.
|
|
@@ -31,9 +32,17 @@ distiller (RLM actor) -> executor (RLM actor) -> responder (synthesizer)
|
|
|
31
32
|
```
|
|
32
33
|
|
|
33
34
|
- **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
|
-
- **executor**
|
|
35
|
+
- **executor** runs unless the distiller skipped it (below). It receives non-context inputs plus `inputs.executorRequest`, a compact `distilledContextSummary` prompt field, and the real evidence live as `inputs.distilledContext` from the distiller's `final(request, evidence)` payload. Declared or auto-promoted context fields stay runtime-readable as `inputs.<field>` when `contextMetadata` lists them, but their raw contents are not pasted into the executor prompt. 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
36
|
- **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
37
|
|
|
38
|
+
### Direct respond (executor skip)
|
|
39
|
+
|
|
40
|
+
With `directResponse: 'auto'` (the default), the distiller can end the run with the `respond(task, evidence)` primitive when the task needs no user-provided functions — the executor stage is skipped entirely (zero executor model calls) and the responder synthesizes straight from the distiller's evidence. Unlike `final`, whose evidence stays live in the shared session by reference, `respond`'s evidence crosses into the responder prompt (budgeted by `maxEvidenceChars`), and the distiller's runtime variables are exported as the cross-run state exactly as the executor's would have been.
|
|
41
|
+
|
|
42
|
+
- **Static agents** (no `functions`, no child agents) run respond-only: `final` is not offered to the distiller and every run is distiller → responder.
|
|
43
|
+
- **Agents with functions** get `respond` alongside `final` under a conservative covenant: only for tasks answered purely by reading/synthesizing provided context, never when a listed function/module domain covers the need, never for current/live/fresh-state asks (context may be stale — tools are the source of truth for "now"), never for side effects. Landing-gate eval (both pinned models, 3 repeats): 0 false skips on tool-required tasks including a stale-context trap, 100% skip recall on pure context Q&A.
|
|
44
|
+
- `directResponse: 'off'` removes the primitive from the prompt and the runtime, and the pipeline rejects a respond payload outright.
|
|
45
|
+
|
|
37
46
|
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
47
|
|
|
39
48
|
- Successful code leaves variables, functions, imports, and computed values available in the runtime session.
|
|
@@ -142,6 +151,7 @@ Use these top-level controls consistently:
|
|
|
142
151
|
- `contextPolicy`: replay/checkpointing/compression policy.
|
|
143
152
|
- `contextMap`: optional persistent orientation cache injected into the distiller and updated once after each successful run. `AxAgentContextMap` evolves indefinitely by default; use `{ infiniteEvolve: false, evolveSteps: N }` on the map object for finite warmup followed by reuse.
|
|
144
153
|
- `contextOptions`: distiller-stage forward options.
|
|
154
|
+
- `autoUpgrade`: smart defaults, ON by default. Auto-enables `functionDiscovery` for large tool catalogs and keeps oversized undeclared input values runtime-only with a truncated prompt preview. Set `false` to opt out, or tune per side: `{ functionDiscovery?: boolean | { aboveFunctionDocChars }, contextFields?: boolean | { promoteAboveChars, previewChars } }`. Explicit `functionDiscovery` and declared `contextFields` always win.
|
|
145
155
|
- `executorOptions`: executor-stage forward options such as `description`, `model`, `modelConfig`, `thinkingTokenBudget`, and `showThoughts`.
|
|
146
156
|
- `executorModelPolicy`: executor-only model override rules based on consecutive error turns or discovery fetches from listed namespaces.
|
|
147
157
|
- `responderOptions`: responder-stage forward options.
|
|
@@ -250,7 +260,7 @@ Prompt/cache shape:
|
|
|
250
260
|
|
|
251
261
|
- Actor turns are compact observable turns, not replayed chat transcripts.
|
|
252
262
|
- 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`, `
|
|
263
|
+
- Cached working inputs: task inputs, inline context, `contextMetadata`, `contextMap`, `memories`, `executorRequest`, `distilledContextSummary`, `discoveredToolDocs`, `loadedSkills`, and `summarizedActorLog`.
|
|
254
264
|
- Dynamic turn tail: `guidanceLog`, `actionLog`, `liveRuntimeState`, and `contextPressure`.
|
|
255
265
|
- Prefer one compact inspection per non-final turn. Never combine inspection output with `final(...)` or `askClarification(...)`.
|
|
256
266
|
|
|
@@ -476,6 +486,7 @@ Flagship real-world long-agents (also ported to Python, Go, Rust, Java, and C++
|
|
|
476
486
|
- [Incident Log Forensics](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/typescript/long-agents/incident-log-forensics.ts) - large-context log forensics over `contextFields` (Gemini)
|
|
477
487
|
- [Codebase Peek Map](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/typescript/long-agents/codebase-peek-map.ts) - Peek-paper context-map orientation over a large repo snapshot
|
|
478
488
|
- [Data Analyst with Tools](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/typescript/long-agents/data-analyst-with-tools.ts) - large data dictionary in `contextFields` + typed warehouse tools the model queries instead of inlining
|
|
489
|
+
- [Smart Defaults Agent](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/typescript/long-agents/smart-defaults-agent.ts) - oversized undeclared context auto-promoted runtime-only, with relevance hints and runtime tools
|
|
479
490
|
- [Self-Improving Lab](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/typescript/long-agents/self-improving-lab.ts) - many-tool agent that runs experiments, grades them with an independent verifier, and distills verified rules into memory
|
|
480
491
|
|
|
481
492
|
## Do Not Generate
|
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: "
|
|
4
|
+
version: "23.0.0"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Codegen Rules (@ax-llm/ax)
|
|
@@ -45,6 +45,8 @@ Map user intent to agent shape before writing code:
|
|
|
45
45
|
- Use `agent(...)` factory syntax for new code.
|
|
46
46
|
- Add child agents to the parent's `functions: [...]` list. Each child's `agentIdentity.namespace` (or `utils`, the default) determines the runtime call site, e.g. `await team.writer({...})`.
|
|
47
47
|
- If discovery is enabled, call `discover(...)` before using callables whose docs are not already in the prompt.
|
|
48
|
+
- `autoUpgrade` is ON by default: large tool catalogs auto-enable discovery, and oversized undeclared input values are auto-kept runtime-only with a truncated prompt preview. Explicit `functionDiscovery` and declared `contextFields` always win; set `autoUpgrade: false` to opt out.
|
|
49
|
+
- `directResponse` is ON by default (`'auto'`): when a task needs no user-provided functions, the distiller ends the run with `respond(task, evidence)` and the executor stage is skipped (zero executor model calls). Function-less agents run respond-only every time; agents with functions offer `respond` under a conservative covenant (no live/fresh-state asks, no side effects, nothing a listed function/module domain covers). Set `directResponse: 'off'` to always run the executor.
|
|
48
50
|
- If a host-side `AxAgentFunction` needs to end the current actor turn, use `extra.protocol.final(...)` or `extra.protocol.askClarification(...)`.
|
|
49
51
|
- In public `forward()` and `streamingForward()` flows, `askClarification(...)` throws `AxAgentClarificationError`; it does not go through the responder.
|
|
50
52
|
- When resuming after clarification, prefer `error.getState()` from the thrown `AxAgentClarificationError`, then call `agent.setState(savedState)` before the next `forward(...)`.
|
|
@@ -260,6 +262,7 @@ Rules:
|
|
|
260
262
|
- A group is `{ namespace, title, description, functions: [...] }`.
|
|
261
263
|
- `selectionCriteria` is optional but useful in discovery mode; it tells the actor when to choose that module.
|
|
262
264
|
- The group's `namespace`, `title`, `selectionCriteria`, and `description` show up in `discover(...)` module docs.
|
|
265
|
+
- `relevanceRanking` (default ON — set `false` to opt out): a deterministic local ranker that injects an advisory `### Likely Relevant` shortlist into the executor turn (dynamic, non-cached field — the cached prompt stays byte-stable). Enabled by default after its A/B gate passed on both small and frontier models and implemented in the generated language ports through AxIR Core. Details in `ax-agent-memory-skills`; outcomes observable via the `relevance_ranking` context event (`ax-agent-observability`).
|
|
263
266
|
- 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.
|
|
264
267
|
- Keep `functions: [...]` either flat or grouped. Runtime validation rejects mixed plain function entries and group objects.
|
|
265
268
|
- In flat mode, pass `fn(...)` tools, child agents, and `toFunction()` providers directly.
|
|
@@ -525,6 +528,7 @@ agent(signature, {
|
|
|
525
528
|
contextFields,
|
|
526
529
|
functions,
|
|
527
530
|
functionDiscovery,
|
|
531
|
+
autoUpgrade,
|
|
528
532
|
...agentOptions,
|
|
529
533
|
});
|
|
530
534
|
```
|
|
@@ -552,6 +556,26 @@ Each `contextFields` entry is either a plain field name string or an object cont
|
|
|
552
556
|
|
|
553
557
|
Use `promptMaxChars` when partial data is worse than no data. Use `keepInPromptChars` when a prefix or suffix alone is useful. The two options are mutually exclusive on one field.
|
|
554
558
|
|
|
559
|
+
### Auto-upgrade defaults
|
|
560
|
+
|
|
561
|
+
`autoUpgrade` is ON by default: the agent applies both knobs above on the user's behalf based on character counts, so forgetting them no longer floods prompts.
|
|
562
|
+
|
|
563
|
+
- Function discovery: when `functionDiscovery` is left unset and the estimated inline docs of discoverable functions exceed ~10k chars, discovery is enabled automatically. An explicit `functionDiscovery: true | false` always wins.
|
|
564
|
+
- Context fields: per run, an undeclared input value whose serialized size exceeds 8k chars is kept runtime-only like a declared context field — the prompt gets a 1,200-char truncated preview plus a `contextMetadata` entry, while the full value stays addressable as `inputs.<field>` in the code runtime (the responder stage gets the same preview). Fields declared in `contextFields` keep their declared config.
|
|
565
|
+
|
|
566
|
+
```typescript
|
|
567
|
+
autoUpgrade?: boolean | {
|
|
568
|
+
functionDiscovery?: boolean | { aboveFunctionDocChars?: number }; // default 10_000
|
|
569
|
+
contextFields?: boolean | { promoteAboveChars?: number; previewChars?: number }; // 8_000 / 1_200
|
|
570
|
+
}
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
Rules:
|
|
574
|
+
|
|
575
|
+
- Set `autoUpgrade: false` (or disable one side) to restore fully manual behavior.
|
|
576
|
+
- Values in required non-string fields (arrays, objects, numbers, media) are never auto-promoted — declare those in `contextFields` explicitly when they can be large.
|
|
577
|
+
- Each promotion emits a `field_auto_promoted` context event (`onContextEvent`) with the field name, original size, and preview size; use it to observe what was kept out of the prompt.
|
|
578
|
+
|
|
555
579
|
## Public Surface
|
|
556
580
|
|
|
557
581
|
Use these method groups as the compact AxAgent surface map:
|
|
@@ -590,6 +614,7 @@ Fetch these for full working code:
|
|
|
590
614
|
- [Smart Home](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/smart-home.ts) - state management
|
|
591
615
|
- [Customer Support](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/customer-support.ts) - classification agent
|
|
592
616
|
- [Abort Patterns](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/abort-patterns.ts) - abort handling
|
|
617
|
+
- [Smart Defaults Agent](https://raw.githubusercontent.com/ax-llm/ax/refs/heads/main/src/examples/typescript/long-agents/smart-defaults-agent.ts) - auto-upgrade context promotion, relevance hints, and runtime tools
|
|
593
618
|
|
|
594
619
|
RLM examples are listed in `ax-agent-rlm`. Memory/skills examples are listed in `ax-agent-memory-skills`.
|
|
595
620
|
|
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: "
|
|
4
|
+
version: "23.0.0"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AI Provider Codegen Rules (@ax-llm/ax)
|
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: "
|
|
4
|
+
version: "23.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: "
|
|
4
|
+
version: "23.0.0"
|
|
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(), validation, assertions, streaming assertions, field processors, step hooks, self-tuning, or structured outputs.
|
|
4
|
-
version: "
|
|
4
|
+
version: "23.0.0"
|
|
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: "
|
|
4
|
+
version: "23.0.0"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# GEPA Optimization 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: "
|
|
4
|
+
version: "23.0.0"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Ax Library (@ax-llm/ax) Quick Reference
|
package/skills/ax-playbook.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-playbook
|
|
3
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: "
|
|
4
|
+
version: "23.0.0"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Playbook Codegen Rules (@ax-llm/ax)
|
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: "
|
|
4
|
+
version: "23.0.0"
|
|
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: "
|
|
4
|
+
version: "23.0.0"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Ax Signature Reference
|