@ax-llm/ax 19.0.1 → 19.0.3
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 +145 -139
- package/index.cjs.map +1 -1
- package/index.d.cts +18 -24
- package/index.d.ts +18 -24
- package/index.global.js +232 -226
- package/index.global.js.map +1 -1
- package/index.js +147 -141
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/ax-agent.md +19 -16
- package/skills/ax-llm.md +1 -1
package/package.json
CHANGED
package/skills/ax-agent.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ax-agent
|
|
3
3
|
description: This skill helps with building AxAgent-based agents using @ax-llm/ax. Use when the user asks about agent(), AxAgent, child agents, tool functions, RLM mode, stopping agents, composing multi-agent hierarchies, shared fields, shared agents, or global shared fields/agents.
|
|
4
|
-
version: "19.0.
|
|
4
|
+
version: "19.0.3"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxAgent Guide (@ax-llm/ax)
|
|
@@ -84,8 +84,8 @@ const myAgent = agent(
|
|
|
84
84
|
|
|
85
85
|
// Optional
|
|
86
86
|
ai: llm, // Bind a specific AI service
|
|
87
|
-
contextFields: ['...'], //
|
|
88
|
-
functions: { local: [searchTool, calcTool] }, // Agent functions (
|
|
87
|
+
contextFields: ['...'], // Runtime context fields (supports string or { field, promptMaxChars })
|
|
88
|
+
functions: { local: [searchTool, calcTool] }, // Agent functions (AxFunction)
|
|
89
89
|
agents: { local: [childAgent1, childAgent2] }, // Child agents
|
|
90
90
|
debug: false, // Debug logging
|
|
91
91
|
// ... other RLM options (see RLM section below)
|
|
@@ -416,7 +416,7 @@ When you pass a long document to an LLM, you face:
|
|
|
416
416
|
|
|
417
417
|
### How It Works
|
|
418
418
|
|
|
419
|
-
1. **Context extraction** — Fields listed in `contextFields` are
|
|
419
|
+
1. **Context extraction** — Fields listed in `contextFields` are loaded into the runtime and are always available as `inputs.<field>`. String-form entries stay runtime-only. Object-form entries (`{ field, promptMaxChars }`) may also be inlined into Actor prompt inputs when compact (default `promptMaxChars: 1200`).
|
|
420
420
|
2. **Actor/Responder split** — The agent uses two internal programs:
|
|
421
421
|
- **Actor** — A code generation agent that writes JavaScript to analyze context data. It NEVER generates final answers directly.
|
|
422
422
|
- **Responder** — An answer synthesis agent that produces the final answer from the Actor's `actorResult` payload. It NEVER generates code.
|
|
@@ -442,7 +442,7 @@ const analyzer = agent(
|
|
|
442
442
|
name: 'documentAnalyzer',
|
|
443
443
|
description: 'Analyzes long documents using code interpreter and sub-LM queries',
|
|
444
444
|
},
|
|
445
|
-
contextFields: ['context'],
|
|
445
|
+
contextFields: [{ field: 'context', promptMaxChars: 1200 }], // Runtime context + optional Actor inlining when small
|
|
446
446
|
runtime: new AxJSRuntime(), // Code runtime (default: AxJSRuntime)
|
|
447
447
|
maxLlmCalls: 30, // Cap on sub-LM calls (default: 50)
|
|
448
448
|
maxRuntimeChars: 2_000, // Cap for llmQuery context + code output (default: 5000)
|
|
@@ -682,7 +682,7 @@ const analyzer = agent('context:string, query:string -> answer:string', {
|
|
|
682
682
|
});
|
|
683
683
|
```
|
|
684
684
|
|
|
685
|
-
Each `llmQuery` call runs a sub-query with a fresh session and the same registered tool/agent globals. The child receives only the `context`
|
|
685
|
+
Each `llmQuery` call runs a sub-query with a fresh session and the same registered tool/agent globals. The child receives only the `context` value passed to `llmQuery(...)` — parent `contextFields` values are not forwarded. In simple mode (default), the child is a plain AxGen (direct LLM call). In advanced mode, the child is a full AxAgent with Actor/Responder and code runtime.
|
|
686
686
|
|
|
687
687
|
### Actor/Responder Descriptions
|
|
688
688
|
|
|
@@ -751,14 +751,15 @@ Demo values are validated against the target program's signature. Invalid values
|
|
|
751
751
|
|
|
752
752
|
| API | Description |
|
|
753
753
|
|-----|-------------|
|
|
754
|
-
| `await llmQuery(query, context)` | Ask a sub-LM a question with
|
|
754
|
+
| `await llmQuery(query, context?)` | Ask a sub-LM a question with optional context. Returns a string. Oversized context is truncated to `maxRuntimeChars` |
|
|
755
|
+
| `await llmQuery({ query, context? })` | Single-object convenience form of `llmQuery`. Returns a string |
|
|
755
756
|
| `await llmQuery([{ query, context }, ...])` | Run multiple sub-LM queries in parallel. Returns string[]. Failed items return `[ERROR] ...` |
|
|
756
757
|
| `final(...args)` | Stop Actor execution and pass payload args to Responder. Requires at least one argument |
|
|
757
758
|
| `ask_clarification(...args)` | Stop Actor execution and pass clarification payload args to Responder. Requires at least one argument |
|
|
758
759
|
| `await agents.<name>({...})` | Call a child agent by name. Parameters match the agent's JSON schema. Returns a string |
|
|
759
760
|
| `await <namespace>.<name>({...})` | Call an agent function. Registered under `namespace.name` (default namespace: `utils`) |
|
|
760
761
|
| `print(...args)` | Available in `AxJSRuntime` when `outputMode: 'stdout'`; captured output appears in the function result |
|
|
761
|
-
| Context variables | All fields
|
|
762
|
+
| Context variables | All input fields are available as `inputs.<field>` (including context fields). Non-colliding top-level aliases may also exist |
|
|
762
763
|
|
|
763
764
|
By default, `AxJSRuntime` uses `outputMode: 'stdout'`, where visible output comes from `console.log(...)`, `print(...)`, and other captured stdout lines.
|
|
764
765
|
|
|
@@ -888,7 +889,7 @@ Thrown by `AxJSRuntime` when consecutive execution failures reach `consecutiveEr
|
|
|
888
889
|
|
|
889
890
|
```typescript
|
|
890
891
|
interface AxRLMConfig {
|
|
891
|
-
contextFields: string[]; //
|
|
892
|
+
contextFields: string[]; // Normalized runtime context field names (AxAgentOptions accepts string or object-form inputs)
|
|
892
893
|
runtime?: AxCodeRuntime; // Code runtime (default: AxJSRuntime)
|
|
893
894
|
maxLlmCalls?: number; // Cap on sub-LM calls (default: 50)
|
|
894
895
|
maxRuntimeChars?: number; // Cap for llmQuery context + code output (default: 5000)
|
|
@@ -937,19 +938,21 @@ interface AxAgentConfig<IN, OUT> extends AxAgentOptions {
|
|
|
937
938
|
}
|
|
938
939
|
```
|
|
939
940
|
|
|
940
|
-
### `
|
|
941
|
+
### `AxFunction`
|
|
941
942
|
|
|
942
943
|
```typescript
|
|
943
|
-
type
|
|
944
|
+
type AxFunction = {
|
|
944
945
|
name: string;
|
|
945
946
|
description: string;
|
|
946
|
-
parameters
|
|
947
|
+
parameters?: AxFunctionJSONSchema;
|
|
947
948
|
returns?: AxFunctionJSONSchema;
|
|
948
949
|
namespace?: string; // default: 'utils'
|
|
949
950
|
func: AxFunctionHandler;
|
|
950
951
|
};
|
|
951
952
|
```
|
|
952
953
|
|
|
954
|
+
For `agent(..., { functions })`, `parameters` is required at runtime.
|
|
955
|
+
|
|
953
956
|
### `AxAgentOptions`
|
|
954
957
|
|
|
955
958
|
Extends `AxProgramForwardOptions` (without `functions`) with:
|
|
@@ -957,7 +960,7 @@ Extends `AxProgramForwardOptions` (without `functions`) with:
|
|
|
957
960
|
```typescript
|
|
958
961
|
{
|
|
959
962
|
debug?: boolean;
|
|
960
|
-
contextFields: string[];
|
|
963
|
+
contextFields: readonly (string | { field: string; promptMaxChars?: number })[];
|
|
961
964
|
|
|
962
965
|
agents?: {
|
|
963
966
|
local?: AxAnyAgentic[]; // Agents callable under the agents.* namespace
|
|
@@ -973,9 +976,9 @@ Extends `AxProgramForwardOptions` (without `functions`) with:
|
|
|
973
976
|
};
|
|
974
977
|
|
|
975
978
|
functions?: {
|
|
976
|
-
local?:
|
|
977
|
-
shared?:
|
|
978
|
-
globallyShared?:
|
|
979
|
+
local?: AxFunction[]; // Registered as namespace.name globals in the JS runtime
|
|
980
|
+
shared?: AxFunction[]; // Shared with direct child agents (one level)
|
|
981
|
+
globallyShared?: AxFunction[]; // Shared with ALL descendants recursively
|
|
979
982
|
excluded?: string[]; // Function names this agent should NOT receive from parents
|
|
980
983
|
};
|
|
981
984
|
|
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.3"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# Ax Library (@ax-llm/ax) Usage Guide
|