@ax-llm/ax 19.0.37 → 19.0.39
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 +82 -70
- package/index.cjs.map +1 -1
- package/index.d.cts +59 -7
- package/index.d.ts +59 -7
- package/index.global.js +71 -59
- package/index.global.js.map +1 -1
- package/index.js +81 -69
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/ax-agent-optimize.md +1 -1
- package/skills/ax-agent.md +92 -2
- package/skills/ax-ai.md +1 -1
- package/skills/ax-flow.md +1 -1
- package/skills/ax-gen.md +53 -1
- package/skills/ax-gepa.md +1 -1
- package/skills/ax-learn.md +1 -1
- package/skills/ax-llm.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-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.
|
|
4
|
+
version: "19.0.39"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Optimize Codegen Rules (@ax-llm/ax)
|
package/skills/ax-agent.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-agent
|
|
3
3
|
description: This skill helps an LLM generate correct 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, recursionOptions, or agent runtime behavior. For tuning and eval with agent.optimize(...), use ax-agent-optimize.
|
|
4
|
-
version: "19.0.
|
|
4
|
+
version: "19.0.39"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Codegen Rules (@ax-llm/ax)
|
|
@@ -724,6 +724,7 @@ Important:
|
|
|
724
724
|
- `output` is not raw stdout; it is the formatted replay string used in the action log.
|
|
725
725
|
- `result` is the raw runtime result before Ax applies type-aware serialization and budget-proportional truncation.
|
|
726
726
|
- `thought` is optional and only appears when the underlying `AxGen` call had `showThoughts` enabled and the provider actually returned a thought field.
|
|
727
|
+
- `actionLogEntryCount` and `guidanceLogEntryCount` reflect the live log sizes after the turn is processed, including resumed runs.
|
|
727
728
|
|
|
728
729
|
Good pattern:
|
|
729
730
|
|
|
@@ -731,9 +732,20 @@ Good pattern:
|
|
|
731
732
|
const supportAgent = agent('query:string -> answer:string', {
|
|
732
733
|
contextFields: ['query'],
|
|
733
734
|
runtime,
|
|
734
|
-
actorTurnCallback: ({
|
|
735
|
+
actorTurnCallback: ({
|
|
736
|
+
turn,
|
|
737
|
+
actionLogEntryCount,
|
|
738
|
+
guidanceLogEntryCount,
|
|
739
|
+
code,
|
|
740
|
+
result,
|
|
741
|
+
output,
|
|
742
|
+
thought,
|
|
743
|
+
isError,
|
|
744
|
+
}) => {
|
|
735
745
|
console.log({
|
|
736
746
|
turn,
|
|
747
|
+
actionLogEntryCount,
|
|
748
|
+
guidanceLogEntryCount,
|
|
737
749
|
isError,
|
|
738
750
|
code,
|
|
739
751
|
rawResult: result,
|
|
@@ -1137,6 +1149,8 @@ agentIdentity?: {
|
|
|
1137
1149
|
actorFields?: string[];
|
|
1138
1150
|
actorTurnCallback?: (turn: {
|
|
1139
1151
|
turn: number;
|
|
1152
|
+
actionLogEntryCount: number;
|
|
1153
|
+
guidanceLogEntryCount: number;
|
|
1140
1154
|
actorResult: Record<string, unknown>;
|
|
1141
1155
|
code: string;
|
|
1142
1156
|
result: unknown;
|
|
@@ -1186,6 +1200,82 @@ agentIdentity?: {
|
|
|
1186
1200
|
- Consecutive error turns reset after a successful non-error turn and when checkpoint summarization refreshes to a new fingerprint.
|
|
1187
1201
|
- `maxSubAgentCalls` is a shared delegated-call budget across the entire run.
|
|
1188
1202
|
|
|
1203
|
+
## Observability: getChatLog() and getUsage()
|
|
1204
|
+
|
|
1205
|
+
`AxAgent` exposes two sub-programs (Actor and Responder). Both `getChatLog()` and `getUsage()` return an object split by role — unlike `AxGen`, which returns a flat array.
|
|
1206
|
+
|
|
1207
|
+
### getChatLog()
|
|
1208
|
+
|
|
1209
|
+
Returns the full normalized chat history split by actor/responder after any `.forward()` call. Each entry is one `ai.chat()` round-trip. The actor accumulates one entry per turn; the responder typically has one.
|
|
1210
|
+
|
|
1211
|
+
```typescript
|
|
1212
|
+
const log = myAgent.getChatLog();
|
|
1213
|
+
// { actor: AxChatLogEntry[], responder: AxChatLogEntry[] }
|
|
1214
|
+
|
|
1215
|
+
for (const entry of log.actor) {
|
|
1216
|
+
console.log('Actor model:', entry.model);
|
|
1217
|
+
for (const msg of entry.messages) {
|
|
1218
|
+
console.log(`[${msg.role}]`, msg.content);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
for (const entry of log.responder) {
|
|
1223
|
+
console.log('Responder model:', entry.model);
|
|
1224
|
+
for (const msg of entry.messages) {
|
|
1225
|
+
console.log(`[${msg.role}]`, msg.content);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
```
|
|
1229
|
+
|
|
1230
|
+
Each `AxChatLogEntry` captures the full prompt sent to the model and its response:
|
|
1231
|
+
|
|
1232
|
+
```typescript
|
|
1233
|
+
type AxChatLogMessage =
|
|
1234
|
+
| { role: 'system'; content: string } // system prompt (includes <tools> block when functions present)
|
|
1235
|
+
| { role: 'user'; content: string }
|
|
1236
|
+
| { role: 'assistant'; content: string } // may contain <think>...</think> and <tool_call>{...}</tool_call>
|
|
1237
|
+
| { role: 'tool'; name: string; content: string };
|
|
1238
|
+
|
|
1239
|
+
type AxChatLogEntry = {
|
|
1240
|
+
model: string;
|
|
1241
|
+
messages: AxChatLogMessage[];
|
|
1242
|
+
modelUsage?: AxProgramUsage;
|
|
1243
|
+
};
|
|
1244
|
+
```
|
|
1245
|
+
|
|
1246
|
+
### getUsage()
|
|
1247
|
+
|
|
1248
|
+
Returns token usage split by actor/responder. Each sub-array contains one `AxProgramUsage` entry per model/run, merged by `(ai, model)` key.
|
|
1249
|
+
|
|
1250
|
+
```typescript
|
|
1251
|
+
const usage = myAgent.getUsage();
|
|
1252
|
+
// { actor: AxProgramUsage[], responder: AxProgramUsage[] }
|
|
1253
|
+
|
|
1254
|
+
console.log('Actor tokens:', usage.actor[0]?.tokens);
|
|
1255
|
+
console.log('Responder tokens:', usage.responder[0]?.tokens);
|
|
1256
|
+
```
|
|
1257
|
+
|
|
1258
|
+
### resetUsage()
|
|
1259
|
+
|
|
1260
|
+
Resets both actor and responder usage at once:
|
|
1261
|
+
|
|
1262
|
+
```typescript
|
|
1263
|
+
myAgent.resetUsage();
|
|
1264
|
+
```
|
|
1265
|
+
|
|
1266
|
+
### Type signatures
|
|
1267
|
+
|
|
1268
|
+
```typescript
|
|
1269
|
+
// AxAgent
|
|
1270
|
+
agent.getChatLog(): { actor: readonly AxChatLogEntry[]; responder: readonly AxChatLogEntry[] }
|
|
1271
|
+
agent.getUsage(): { actor: AxProgramUsage[]; responder: AxProgramUsage[] }
|
|
1272
|
+
agent.resetUsage(): void
|
|
1273
|
+
|
|
1274
|
+
// AxGen (flat — no split)
|
|
1275
|
+
gen.getChatLog(): readonly AxChatLogEntry[]
|
|
1276
|
+
gen.getUsage(): AxProgramUsage[]
|
|
1277
|
+
```
|
|
1278
|
+
|
|
1189
1279
|
## Examples
|
|
1190
1280
|
|
|
1191
1281
|
Fetch these for full working code:
|
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.
|
|
4
|
+
version: "19.0.39"
|
|
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.
|
|
4
|
+
version: "19.0.39"
|
|
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.
|
|
4
|
+
version: "19.0.39"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxGen Codegen Rules (@ax-llm/ax)
|
|
@@ -299,6 +299,58 @@ Rules:
|
|
|
299
299
|
- `AxGenerateError` includes `details` with `model` and `signature` for debugging.
|
|
300
300
|
- `AxAIServiceAbortedError` is thrown on cancellation via `stop()` or `abortSignal`.
|
|
301
301
|
|
|
302
|
+
## Chat Log and Usage
|
|
303
|
+
|
|
304
|
+
### getChatLog()
|
|
305
|
+
|
|
306
|
+
After any `.forward()` or `streamingForward()` call, `gen.getChatLog()` returns the full normalized chat history — every `ai.chat()` round-trip, including the system prompt, all messages, and the model response. The log is reset at the start of each `.forward()` call. Multi-step generators (with function calls) produce one entry per step.
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
await gen.forward(llm, { question: 'What is 2+2?' });
|
|
310
|
+
|
|
311
|
+
for (const entry of gen.getChatLog()) {
|
|
312
|
+
console.log('model:', entry.model);
|
|
313
|
+
for (const msg of entry.messages) {
|
|
314
|
+
console.log(`[${msg.role}]`, msg.content);
|
|
315
|
+
}
|
|
316
|
+
console.log('tokens:', entry.modelUsage?.tokens);
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Message roles: `system`, `user`, `assistant`, `tool`. Assistant content uses inline XML:
|
|
321
|
+
- `<think>...</think>` — reasoning/thinking tokens
|
|
322
|
+
- `<tool_call>\n{...}\n</tool_call>` — tool invocations
|
|
323
|
+
|
|
324
|
+
The system message includes a `<tools>` JSON block when functions are present.
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
type AxChatLogMessage =
|
|
328
|
+
| { role: 'system'; content: string }
|
|
329
|
+
| { role: 'user'; content: string }
|
|
330
|
+
| { role: 'assistant'; content: string }
|
|
331
|
+
| { role: 'tool'; name: string; content: string };
|
|
332
|
+
|
|
333
|
+
type AxChatLogEntry = {
|
|
334
|
+
model: string;
|
|
335
|
+
messages: AxChatLogMessage[];
|
|
336
|
+
modelUsage?: AxProgramUsage;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
gen.getChatLog(): readonly AxChatLogEntry[]
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### getUsage()
|
|
343
|
+
|
|
344
|
+
Returns token usage aggregated by `(ai, model)` across all steps. Reset with `resetUsage()`.
|
|
345
|
+
|
|
346
|
+
```typescript
|
|
347
|
+
const usage = gen.getUsage(); // AxProgramUsage[]
|
|
348
|
+
console.log(usage[0]?.tokens?.promptTokens);
|
|
349
|
+
gen.resetUsage();
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
> For `AxAgent`, both `getChatLog()` and `getUsage()` return `{ actor: ..., responder: ... }` — see `ax-agent` skill.
|
|
353
|
+
|
|
302
354
|
## Examples
|
|
303
355
|
|
|
304
356
|
Fetch these for full working code:
|
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.
|
|
4
|
+
version: "19.0.39"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxGEPA Codegen Rules (@ax-llm/ax)
|
package/skills/ax-learn.md
CHANGED
|
@@ -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.
|
|
4
|
+
version: "19.0.39"
|
|
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.
|
|
4
|
+
version: "19.0.39"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Ax Library (@ax-llm/ax) Quick Reference
|
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: "19.0.
|
|
4
|
+
version: "19.0.39"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Ax Signature Reference
|