@amitdeshmukh/ax-crew 8.7.1 → 9.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/CHANGELOG.md +49 -0
- package/README.md +10 -10
- package/axcrew.webp +0 -0
- package/dist/agents/agentConfig.d.ts +2 -0
- package/dist/agents/agentConfig.js +11 -4
- package/dist/agents/crew.d.ts +59 -0
- package/dist/agents/crew.js +355 -0
- package/dist/agents/deferredTools.d.ts +49 -0
- package/dist/agents/deferredTools.js +237 -0
- package/dist/agents/index.d.ts +4 -266
- package/dist/agents/index.js +3 -1014
- package/dist/agents/lazyAgent.d.ts +33 -0
- package/dist/agents/lazyAgent.js +78 -0
- package/dist/agents/statefulAgent.d.ts +93 -0
- package/dist/agents/statefulAgent.js +473 -0
- package/dist/index.d.ts +2 -2
- package/dist/types.d.ts +18 -1
- package/examples/graphjin-database-agent.ts +68 -57
- package/examples/write-post-and-publish-to-wordpress.ts +1 -1
- package/package.json +1 -1
- package/scripts/install-skills.mjs +62 -30
- package/scripts/uninstall-skills.mjs +19 -13
- package/src/agents/agentConfig.ts +14 -8
- package/src/agents/crew.ts +443 -0
- package/src/agents/deferredTools.ts +275 -0
- package/src/agents/index.ts +4 -1281
- package/src/agents/lazyAgent.ts +95 -0
- package/src/agents/statefulAgent.ts +659 -0
- package/src/index.ts +7 -4
- package/src/skills/{ax-crew-ace.md → axcrew-ace.md} +9 -4
- package/src/skills/{ax-crew-agent-config.md → axcrew-agent-config.md} +7 -4
- package/src/skills/{ax-crew-code-execution.md → axcrew-code-execution.md} +7 -4
- package/src/skills/{ax-crew-execution-modes.md → axcrew-execution-modes.md} +10 -6
- package/src/skills/{ax-crew-few-shot.md → axcrew-few-shot.md} +8 -4
- package/src/skills/{ax-crew-functions.md → axcrew-functions.md} +10 -7
- package/src/skills/{ax-crew-mcp.md → axcrew-mcp.md} +50 -6
- package/src/skills/{ax-crew-metrics.md → axcrew-metrics.md} +9 -6
- package/src/skills/{ax-crew-patterns.md → axcrew-patterns.md} +56 -8
- package/src/skills/{ax-crew-providers.md → axcrew-providers.md} +12 -7
- package/src/skills/{ax-crew-signatures.md → axcrew-signatures.md} +5 -5
- package/src/skills/{ax-crew-state.md → axcrew-state.md} +23 -20
- package/src/skills/{ax-crew-streaming.md → axcrew-streaming.md} +7 -4
- package/src/skills/{ax-crew-sub-agents.md → axcrew-sub-agents.md} +8 -4
- package/src/skills/{ax-crew-telemetry.md → axcrew-telemetry.md} +6 -3
- package/src/skills/{ax-crew.md → axcrew.md} +22 -6
- package/src/types.ts +19 -0
- package/.claude/settings.local.json +0 -13
- package/.claude/skills/ax-crew/SKILL.md +0 -466
- package/axcrew.png +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
version:
|
|
2
|
+
name: axcrew-ace
|
|
3
|
+
version: 8.7.3
|
|
4
4
|
description: "ACE (Agentic Context Engineering) for AxCrew: feedback loops, online learning, playbook persistence, and optimization."
|
|
5
5
|
tags: [ace, agentic-context-engineering, feedback, learning, playbook, online-update, optimize]
|
|
6
6
|
---
|
|
@@ -150,6 +150,10 @@ async function main() {
|
|
|
150
150
|
main().catch(console.error);
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
+
## Supporting files
|
|
154
|
+
- See [examples/ace-customer-support.ts](examples/ace-customer-support.ts) for a complete runnable example.
|
|
155
|
+
- See [examples/ace-flight-finder.ts](examples/ace-flight-finder.ts) for another ACE example.
|
|
156
|
+
|
|
153
157
|
## Do Not Generate
|
|
154
158
|
|
|
155
159
|
- Do NOT call `initACE()` manually -- it is called automatically when `addAgent()` / `addAgentsToCrew()` detects an `ace` config on the agent.
|
|
@@ -160,6 +164,7 @@ main().catch(console.error);
|
|
|
160
164
|
|
|
161
165
|
## References
|
|
162
166
|
|
|
163
|
-
- [ace-customer-support.ts](
|
|
164
|
-
- [
|
|
167
|
+
- [ace-customer-support.ts](examples/ace-customer-support.ts)
|
|
168
|
+
- [ace-flight-finder.ts](examples/ace-flight-finder.ts)
|
|
169
|
+
- [src/agents/ace.ts](src/agents/ace.ts)
|
|
165
170
|
- [AxACE upstream docs](https://axllm.dev/ace/)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
version:
|
|
2
|
+
name: axcrew-agent-config
|
|
3
|
+
version: 8.7.3
|
|
4
4
|
description: "AgentConfig - agent configuration: provider, signature, model, temperature, definition, prompt, executionMode, axAgentOptions, providerArgs"
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -167,6 +167,9 @@ DSPy-style string signatures with optional field descriptions:
|
|
|
167
167
|
|
|
168
168
|
Supported types: `string`, `number`, `boolean`, `string[]`, `number[]`, etc.
|
|
169
169
|
|
|
170
|
+
## Supporting files
|
|
171
|
+
- See [examples/providerArgs.ts](examples/providerArgs.ts) for a complete runnable example.
|
|
172
|
+
|
|
170
173
|
## Do Not Generate
|
|
171
174
|
|
|
172
175
|
- Do NOT omit `name`, `description`, `signature`, `provider`, or `ai.model` -- all are required.
|
|
@@ -177,5 +180,5 @@ Supported types: `string`, `number`, `boolean`, `string[]`, `number[]`, etc.
|
|
|
177
180
|
|
|
178
181
|
## References
|
|
179
182
|
|
|
180
|
-
- [basic-researcher-writer.ts](
|
|
181
|
-
- [providerArgs.ts](
|
|
183
|
+
- [basic-researcher-writer.ts](examples/basic-researcher-writer.ts)
|
|
184
|
+
- [providerArgs.ts](examples/providerArgs.ts)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: axcrew-code-execution
|
|
3
3
|
description: AxCrew code execution with AxJSRuntime for sandboxed JavaScript execution. Covers AxJSRuntime setup, permissions, executionMode axagent, RLM mode, and runtime configuration for autonomous code generation and execution.
|
|
4
|
-
version: "
|
|
4
|
+
version: "8.7.3"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxCrew Code Execution
|
|
@@ -152,6 +152,9 @@ const config: AxCrewConfig = {
|
|
|
152
152
|
};
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
+
## Supporting files
|
|
156
|
+
- See [examples/rlm-long-task.ts](examples/rlm-long-task.ts) for a complete runnable example.
|
|
157
|
+
|
|
155
158
|
## Do Not Generate
|
|
156
159
|
|
|
157
160
|
- Do NOT use `executionMode: "axgen"` with `runtime` -- code execution requires `"axagent"` mode
|
|
@@ -162,5 +165,5 @@ const config: AxCrewConfig = {
|
|
|
162
165
|
|
|
163
166
|
## References
|
|
164
167
|
|
|
165
|
-
- [rlm-long-task.ts](
|
|
166
|
-
- [rlm-shared-fields.ts](
|
|
168
|
+
- [rlm-long-task.ts](examples/rlm-long-task.ts) -- full RLM agent with context management
|
|
169
|
+
- [rlm-shared-fields.ts](examples/rlm-shared-fields.ts) -- shared runtime across sub-agents
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
version: "
|
|
2
|
+
name: axcrew-execution-modes
|
|
3
|
+
version: "8.7.3"
|
|
4
4
|
description: "ax-crew execution modes: execution mode, axgen, axagent, RLM, runtime, contextFields, AxJSRuntime, contextManagement, fields, shared, globallyShared, excluded, maxTurns, maxSubAgentCalls"
|
|
5
5
|
argument-hint: [topic]
|
|
6
6
|
allowed-tools: Read, Grep, Glob
|
|
@@ -270,6 +270,10 @@ async function main() {
|
|
|
270
270
|
main().catch(console.error);
|
|
271
271
|
```
|
|
272
272
|
|
|
273
|
+
## Supporting files
|
|
274
|
+
- See [examples/rlm-long-task.ts](examples/rlm-long-task.ts) for a complete runnable example.
|
|
275
|
+
- See [examples/rlm-shared-fields.ts](examples/rlm-shared-fields.ts) for shared fields between agents.
|
|
276
|
+
|
|
273
277
|
## Do Not Generate
|
|
274
278
|
|
|
275
279
|
- Do NOT use `axAgentOptions` without setting `executionMode: "axagent"` -- it is ignored in `axgen` mode.
|
|
@@ -281,7 +285,7 @@ main().catch(console.error);
|
|
|
281
285
|
|
|
282
286
|
## References
|
|
283
287
|
|
|
284
|
-
- [rlm-long-task.ts
|
|
285
|
-
- [rlm-shared-fields.ts
|
|
286
|
-
- [Source: AxCrewAxAgentOptions type](
|
|
287
|
-
- [Source: StatefulAxAgent execution mode handling](
|
|
288
|
+
- [rlm-long-task.ts](examples/rlm-long-task.ts)
|
|
289
|
+
- [rlm-shared-fields.ts](examples/rlm-shared-fields.ts)
|
|
290
|
+
- [Source: AxCrewAxAgentOptions type](src/types.ts)
|
|
291
|
+
- [Source: StatefulAxAgent execution mode handling](src/agents/index.ts)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: axcrew-few-shot
|
|
3
3
|
description: AxCrew few-shot examples via examples[] field in AgentConfig. Covers in-context learning, demonstration structure, input/output field matching, setExamplesCompat() for dynamic updates, and when to use examples vs definition/prompt.
|
|
4
|
-
version: "
|
|
4
|
+
version: "8.7.3"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxCrew Few-Shot Examples
|
|
@@ -151,6 +151,9 @@ const agent = crew.agents?.get("SupportAgent");
|
|
|
151
151
|
|
|
152
152
|
Best practice: use `definition`/`prompt` for WHO the agent is, `examples[]` for HOW it should respond.
|
|
153
153
|
|
|
154
|
+
## Supporting files
|
|
155
|
+
- See [examples/solve-math-problem.ts](examples/solve-math-problem.ts) for a complete runnable example.
|
|
156
|
+
|
|
154
157
|
## Do Not Generate
|
|
155
158
|
|
|
156
159
|
- Do NOT embed examples as text in `definition` or `prompt` -- use the `examples[]` field for structured few-shot learning
|
|
@@ -161,5 +164,6 @@ Best practice: use `definition`/`prompt` for WHO the agent is, `examples[]` for
|
|
|
161
164
|
|
|
162
165
|
## References
|
|
163
166
|
|
|
164
|
-
- [
|
|
165
|
-
- [
|
|
167
|
+
- [solve-math-problem.ts](examples/solve-math-problem.ts) -- agent with few-shot examples
|
|
168
|
+
- [ace-customer-support.ts](examples/ace-customer-support.ts) -- agent with structured examples and ACE feedback
|
|
169
|
+
- [basic-researcher-writer.ts](examples/basic-researcher-writer.ts) -- simple agent config
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
version:
|
|
2
|
+
name: axcrew-functions
|
|
3
|
+
version: 8.7.3
|
|
4
4
|
description: "Functions and tools: FunctionRegistryType, AxFunction, toFunction, custom functions, AxCrewFunctions, class-based functions with state"
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -192,7 +192,7 @@ async function main() {
|
|
|
192
192
|
const crew = new AxCrew(config, customFunctions);
|
|
193
193
|
|
|
194
194
|
// Set state for class-based functions
|
|
195
|
-
crew.
|
|
195
|
+
crew.crewState.set("env", { API_BASE_URL: "https://api.example.com" });
|
|
196
196
|
|
|
197
197
|
await crew.addAllAgents();
|
|
198
198
|
const assistant = crew.agents?.get("assistant");
|
|
@@ -204,15 +204,18 @@ async function main() {
|
|
|
204
204
|
main().catch(console.error);
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
+
## Supporting files
|
|
208
|
+
- See [examples/write-post-and-publish-to-wordpress.ts](examples/write-post-and-publish-to-wordpress.ts) for a complete runnable example.
|
|
209
|
+
|
|
207
210
|
## Do Not Generate
|
|
208
211
|
|
|
209
212
|
- Do NOT define functions inline in AgentConfig; always use a `FunctionRegistryType` registry passed to the `AxCrew` constructor.
|
|
210
|
-
- Do NOT forget that class-based function constructors receive `state: Record<string, any>`, not `StateInstance`. Access values directly (e.g. `this.state.env`), since the state object is a plain record populated via `crew.
|
|
213
|
+
- Do NOT forget that class-based function constructors receive `state: Record<string, any>`, not `StateInstance`. Access values directly (e.g. `this.state.env`), since the state object is a plain record populated via `crew.crewState.set()`.
|
|
211
214
|
- Do NOT use a registry key that differs from the function name used in `AgentConfig.functions[]` -- they must match.
|
|
212
215
|
- Do NOT import `AxCrewFunctions` from `@ax-llm/ax`; import from `@amitdeshmukh/ax-crew`.
|
|
213
216
|
|
|
214
217
|
## References
|
|
215
218
|
|
|
216
|
-
- [write-post-and-publish-to-wordpress.ts](
|
|
217
|
-
- [src/functions/dateTime.ts](
|
|
218
|
-
- [src/functions/index.ts](
|
|
219
|
+
- [write-post-and-publish-to-wordpress.ts](examples/write-post-and-publish-to-wordpress.ts)
|
|
220
|
+
- [src/functions/dateTime.ts](src/functions/dateTime.ts)
|
|
221
|
+
- [src/functions/index.ts](src/functions/index.ts)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
version: "
|
|
2
|
+
name: axcrew-mcp
|
|
3
|
+
version: "9.0.0"
|
|
4
4
|
description: "ax-crew MCP integration: MCP, Model Context Protocol, STDIO, HTTP SSE, Streamable HTTP, mcpServers, tools, tool filtering, multiple servers"
|
|
5
5
|
argument-hint: [topic]
|
|
6
6
|
allowed-tools: Read, Grep, Glob
|
|
@@ -205,6 +205,50 @@ async function main() {
|
|
|
205
205
|
main().catch(console.error);
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
+
## Deferred Tool Loading
|
|
209
|
+
|
|
210
|
+
When an agent has many MCP tools (20+), use the `deferredTools` config to reduce token usage. Only core tools + a `search_tools` meta-function are sent to the LLM. The LLM discovers additional tools on demand. Discovered tools persist across `forward()` calls. Tool results that mention deferred tool names (e.g., error responses suggesting `fix_query_error`) auto-activate those tools.
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
{
|
|
214
|
+
name: "BigMCPAgent",
|
|
215
|
+
description: "Agent with many MCP tools",
|
|
216
|
+
signature: 'query:string -> answer:string',
|
|
217
|
+
provider: "anthropic",
|
|
218
|
+
providerKeyName: "ANTHROPIC_API_KEY",
|
|
219
|
+
ai: { model: "claude-sonnet-4-6", temperature: 0 },
|
|
220
|
+
mcpServers: {
|
|
221
|
+
"large-server": {
|
|
222
|
+
command: "npx",
|
|
223
|
+
args: ["-y", "some-large-mcp-server"],
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
deferredTools: {
|
|
227
|
+
enabled: true, // default: auto (true when tool count > threshold)
|
|
228
|
+
threshold: 20, // tool count to activate deferred mode
|
|
229
|
+
maxSearchResults: 10, // max tools returned per search
|
|
230
|
+
coreTools: ["execute_graphql", "list_tables"], // always keep active
|
|
231
|
+
},
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### What is "core" vs "deferred"
|
|
236
|
+
|
|
237
|
+
- **Core** (always visible): custom functions, sub-agent functions, `resource_*` functions, explicitly listed `coreTools`
|
|
238
|
+
- **Deferred** (discoverable via search): MCP tool functions (except `resource_*`)
|
|
239
|
+
|
|
240
|
+
### Resource Caching
|
|
241
|
+
|
|
242
|
+
MCP `resource_*` functions (reference docs like query syntax guides) are automatically cached in-memory. Repeated calls return the cached result without re-fetching from the MCP server.
|
|
243
|
+
|
|
244
|
+
## Prompt Caching
|
|
245
|
+
|
|
246
|
+
Prompt caching is enabled by default for all agents. System prompts and tool definitions are cached across multi-step interactions via Anthropic's implicit caching or Gemini's context caching. This reduces token costs by up to 6x for agents with many tools — the system prompt (~13K tokens of tool schemas) is processed once and reused on subsequent steps.
|
|
247
|
+
|
|
248
|
+
## Supporting files
|
|
249
|
+
- See [examples/mcp-agent.ts](examples/mcp-agent.ts) for a complete runnable example.
|
|
250
|
+
- See [examples/graphjin-database-agent.ts](examples/graphjin-database-agent.ts) for Streamable HTTP transport.
|
|
251
|
+
|
|
208
252
|
## Do Not Generate
|
|
209
253
|
|
|
210
254
|
- Do NOT mix transport config keys -- use exactly one of `command`, `sseUrl`, or `mcpEndpoint` per server entry.
|
|
@@ -215,7 +259,7 @@ main().catch(console.error);
|
|
|
215
259
|
|
|
216
260
|
## References
|
|
217
261
|
|
|
218
|
-
- [mcp-agent.ts
|
|
219
|
-
- [graphjin-database-agent.ts
|
|
220
|
-
- [Source: agentConfig.ts (initializeMCPServers)](
|
|
221
|
-
- [Types: MCPStdioTransportConfig, MCPHTTPSSETransportConfig, MCPStreamableHTTPTransportConfig](
|
|
262
|
+
- [mcp-agent.ts](examples/mcp-agent.ts)
|
|
263
|
+
- [graphjin-database-agent.ts](examples/graphjin-database-agent.ts)
|
|
264
|
+
- [Source: agentConfig.ts (initializeMCPServers)](src/agents/agentConfig.ts)
|
|
265
|
+
- [Types: MCPStdioTransportConfig, MCPHTTPSSETransportConfig, MCPStreamableHTTPTransportConfig](src/types.ts)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
version: "
|
|
2
|
+
name: axcrew-metrics
|
|
3
|
+
version: "8.7.3"
|
|
4
4
|
description: "ax-crew metrics and cost tracking: metrics, cost, tracking, getMetrics, getCrewMetrics, MetricsSnapshot, usage, tokens, estimatedCostUSD, resetCosts, resetCrewMetrics"
|
|
5
5
|
argument-hint: [topic]
|
|
6
6
|
allowed-tools: Read, Grep, Glob
|
|
@@ -154,6 +154,9 @@ if (m?.functions?.details) {
|
|
|
154
154
|
}
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
+
## Supporting files
|
|
158
|
+
- See [examples/basic-researcher-writer.ts](examples/basic-researcher-writer.ts) for a complete runnable example.
|
|
159
|
+
|
|
157
160
|
## Do Not Generate
|
|
158
161
|
|
|
159
162
|
- Do NOT call `getMetrics()` on the crew object -- use `crew.getCrewMetrics()` for crew-level and `agent.getMetrics()` for per-agent.
|
|
@@ -164,7 +167,7 @@ if (m?.functions?.details) {
|
|
|
164
167
|
|
|
165
168
|
## References
|
|
166
169
|
|
|
167
|
-
- [basic-researcher-writer.ts
|
|
168
|
-
- [rlm-long-task.ts
|
|
169
|
-
- [Source: MetricsSnapshot type](
|
|
170
|
-
- [Source: MetricsRegistry](
|
|
170
|
+
- [basic-researcher-writer.ts](examples/basic-researcher-writer.ts)
|
|
171
|
+
- [rlm-long-task.ts](examples/rlm-long-task.ts)
|
|
172
|
+
- [Source: MetricsSnapshot type](src/metrics/types.ts)
|
|
173
|
+
- [Source: MetricsRegistry](src/metrics/registry.ts)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
version:
|
|
2
|
+
name: axcrew-patterns
|
|
3
|
+
version: 9.0.0
|
|
4
4
|
description: "AxCrew multi-agent patterns: pipeline, delegation, fan-out, orchestrator, sequential workflows, and agent coordination."
|
|
5
5
|
tags: [patterns, workflow, pipeline, multi-agent, orchestrator, delegation, sequential, fan-out]
|
|
6
6
|
---
|
|
@@ -251,8 +251,8 @@ Target audience: intermediate developers familiar with TypeScript.`,
|
|
|
251
251
|
All agents in a crew share a mutable `state` object for out-of-band data passing:
|
|
252
252
|
|
|
253
253
|
```ts
|
|
254
|
-
crew.
|
|
255
|
-
crew.
|
|
254
|
+
crew.crewState.set("env", { WORDPRESS_URL: "http://...", WORDPRESS_USERNAME: "..." });
|
|
255
|
+
crew.crewState.set("context", { userId: "abc-123" });
|
|
256
256
|
|
|
257
257
|
// Inside a custom function, state is accessible via the constructor:
|
|
258
258
|
class MyTool {
|
|
@@ -271,16 +271,64 @@ class MyTool {
|
|
|
271
271
|
}
|
|
272
272
|
```
|
|
273
273
|
|
|
274
|
+
## Cost Optimization Pattern (Single-Delegation Manager)
|
|
275
|
+
|
|
276
|
+
When a manager orchestrates sub-agents, use a **single-delegation** pattern: send the full question to the sub-agent in one call. Do NOT break questions into sub-queries — the sub-agent handles multi-step work internally.
|
|
277
|
+
|
|
278
|
+
This pattern reduced costs from $128 to $1 on the same query in testing.
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
{
|
|
282
|
+
name: "ManagerAgent",
|
|
283
|
+
description: "Orchestrates database queries and analysis tasks",
|
|
284
|
+
definition: `You are an orchestrator that routes questions to specialized agents.
|
|
285
|
+
Delegate each question to the most relevant agent in a SINGLE call — do not break questions into sub-queries.
|
|
286
|
+
The sub-agent will handle all the steps internally. Your job is to route and synthesize, not to decompose.
|
|
287
|
+
If multiple agents are needed, call them and combine their answers.`,
|
|
288
|
+
signature: 'question:string -> answer:string',
|
|
289
|
+
provider: "anthropic" as Provider,
|
|
290
|
+
providerKeyName: "ANTHROPIC_API_KEY",
|
|
291
|
+
ai: { model: "claude-sonnet-4-6", maxTokens: 2000, temperature: 0 },
|
|
292
|
+
agents: ["DatabaseAgent", "AnalyticsAgent"],
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Workflow Reuse Pattern (MCP Agents)
|
|
297
|
+
|
|
298
|
+
For agents connected to MCP servers, use a strategy-driven definition that checks for saved workflows before building new ones. This ensures repeat questions reuse cached workflows ($0.17) instead of rebuilding from scratch ($0.55).
|
|
299
|
+
|
|
300
|
+
```ts
|
|
301
|
+
{
|
|
302
|
+
name: "DatabaseAgent",
|
|
303
|
+
definition: `You answer questions by querying databases via an MCP server.
|
|
304
|
+
|
|
305
|
+
STRATEGY:
|
|
306
|
+
1. Check first — call list_workflows and list_saved_queries. If a match exists, execute it directly.
|
|
307
|
+
2. Learn — read resource docs, list tables, describe schema.
|
|
308
|
+
3. Build — author a JS workflow with server-side computation, validate with a test query.
|
|
309
|
+
4. Save and run — save the workflow for reuse, then execute it.
|
|
310
|
+
5. If a query fails, call fix_query_error to diagnose. Do not retry the same query.
|
|
311
|
+
6. Synthesize the answer from results.`,
|
|
312
|
+
// ...
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## Supporting files
|
|
317
|
+
- See [examples/write-post-and-publish-to-wordpress.ts](examples/write-post-and-publish-to-wordpress.ts) for a complete pipeline example.
|
|
318
|
+
- See [examples/solve-math-problem.ts](examples/solve-math-problem.ts) for a delegation example.
|
|
319
|
+
- See [examples/graphjin-database-agent.ts](examples/graphjin-database-agent.ts) for single-delegation + workflow reuse pattern.
|
|
320
|
+
|
|
274
321
|
## Do Not Generate
|
|
275
322
|
|
|
276
323
|
- Do NOT add a parent agent before its sub-agents -- `addAgentsToCrew` resolves dependencies but `addAgent` does not.
|
|
277
324
|
- Do NOT use `agents: ["SelfName"]` -- an agent cannot be its own sub-agent (circular dependency error).
|
|
278
|
-
- Do NOT assume agents share conversation context -- they share `
|
|
325
|
+
- Do NOT assume agents share conversation context -- they share `crewState` but each `forward()` call is independent. Pass data explicitly via signatures.
|
|
279
326
|
- Do NOT use `definition` shorter than 100 characters -- Ax requires minimum length for program definitions.
|
|
280
327
|
- Do NOT confuse `description` (used as the tool description when this agent is a sub-agent) with `definition` (the system prompt).
|
|
328
|
+
- Do NOT have the manager decompose questions into sub-queries -- send the full question to the sub-agent in one call.
|
|
281
329
|
|
|
282
330
|
## References
|
|
283
331
|
|
|
284
|
-
- [write-post-and-publish-to-wordpress.ts](
|
|
285
|
-
- [solve-math-problem.ts](
|
|
286
|
-
- [search-tweets.ts](
|
|
332
|
+
- [write-post-and-publish-to-wordpress.ts](examples/write-post-and-publish-to-wordpress.ts) (4-agent pipeline)
|
|
333
|
+
- [solve-math-problem.ts](examples/solve-math-problem.ts) (delegation)
|
|
334
|
+
- [search-tweets.ts](examples/search-tweets.ts) (streaming)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
version:
|
|
2
|
+
name: axcrew-providers
|
|
3
|
+
version: 8.7.3
|
|
4
4
|
description: "AxCrew provider configuration: openai, anthropic, google-gemini, azure-openai, groq, ollama, mistral, cohere, grok/xAI, perplexity, and model setup."
|
|
5
5
|
tags: [provider, openai, anthropic, google-gemini, azure, groq, ollama, mistral, cohere, model, grok, perplexity]
|
|
6
6
|
---
|
|
@@ -187,6 +187,11 @@ async function main() {
|
|
|
187
187
|
main().catch(console.error);
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
+
## Supporting files
|
|
191
|
+
- See [examples/providerArgs.ts](examples/providerArgs.ts) for Azure OpenAI configuration.
|
|
192
|
+
- See [examples/search-tweets.ts](examples/search-tweets.ts) for Grok/xAI usage.
|
|
193
|
+
- See [examples/perplexityDeepSearch.ts](examples/perplexityDeepSearch.ts) for Perplexity MCP integration.
|
|
194
|
+
|
|
190
195
|
## Do Not Generate
|
|
191
196
|
|
|
192
197
|
- Do NOT hardcode API keys in config -- always use `providerKeyName` which reads from `process.env`.
|
|
@@ -197,8 +202,8 @@ main().catch(console.error);
|
|
|
197
202
|
|
|
198
203
|
## References
|
|
199
204
|
|
|
200
|
-
- [providerArgs.ts](
|
|
201
|
-
- [search-tweets.ts](
|
|
202
|
-
- [perplexityDeepSearch.ts](
|
|
203
|
-
- [write-post-and-publish-to-wordpress.ts](
|
|
204
|
-
- [src/agents/compose.ts](
|
|
205
|
+
- [providerArgs.ts](examples/providerArgs.ts) (Azure OpenAI)
|
|
206
|
+
- [search-tweets.ts](examples/search-tweets.ts) (Grok/xAI)
|
|
207
|
+
- [perplexityDeepSearch.ts](examples/perplexityDeepSearch.ts) (Perplexity MCP)
|
|
208
|
+
- [write-post-and-publish-to-wordpress.ts](examples/write-post-and-publish-to-wordpress.ts) (mixed providers)
|
|
209
|
+
- [src/agents/compose.ts](src/agents/compose.ts)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: axcrew-signatures
|
|
3
3
|
description: AxCrew DSPy-style signature format for defining agent inputs/outputs. Covers signature syntax, types (string, number, boolean, class, string[], json, image, audio, date), optional fields (?), field descriptions, and AxSignature builder alternative.
|
|
4
|
-
version: "
|
|
4
|
+
version: "8.7.3"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxCrew Signatures
|
|
@@ -164,6 +164,6 @@ const config: AxCrewConfig = {
|
|
|
164
164
|
|
|
165
165
|
## References
|
|
166
166
|
|
|
167
|
-
- [rlm-long-task.ts](
|
|
168
|
-
- [rlm-shared-fields.ts](
|
|
169
|
-
- [ace-customer-support.ts](
|
|
167
|
+
- [rlm-long-task.ts](examples/rlm-long-task.ts) -- array output in signature
|
|
168
|
+
- [rlm-shared-fields.ts](examples/rlm-shared-fields.ts) -- field descriptions in quotes
|
|
169
|
+
- [ace-customer-support.ts](examples/ace-customer-support.ts) -- multi-output signature
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
version:
|
|
2
|
+
name: axcrew-state
|
|
3
|
+
version: 9.0.0
|
|
4
4
|
description: "State management: shared state, StateInstance, set, get, getAll, reset, accessing state from class-based functions"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# State
|
|
8
8
|
|
|
9
|
-
Every `AxCrew` instance has a shared `StateInstance` at `crew.
|
|
9
|
+
Every `AxCrew` instance has a shared `StateInstance` at `crew.crewState`. All agents and class-based functions in the crew can access the same state.
|
|
10
10
|
|
|
11
11
|
## StateInstance API
|
|
12
12
|
|
|
@@ -21,9 +21,9 @@ interface StateInstance {
|
|
|
21
21
|
|
|
22
22
|
## Core Behavior
|
|
23
23
|
|
|
24
|
-
- `crew.
|
|
24
|
+
- `crew.crewState` is created automatically when `new AxCrew(config)` is called.
|
|
25
25
|
- State is keyed by `crewId` (auto-generated UUID). Each crew instance has its own isolated state.
|
|
26
|
-
- State persists for the lifetime of the crew. Calling `crew.destroy()` calls `
|
|
26
|
+
- State persists for the lifetime of the crew. Calling `crew.destroy()` calls `crewState.reset()`.
|
|
27
27
|
- Values can be any type: strings, objects, arrays, etc.
|
|
28
28
|
|
|
29
29
|
## Canonical Pattern
|
|
@@ -53,7 +53,7 @@ class SendEmail {
|
|
|
53
53
|
required: ['to', 'subject', 'body']
|
|
54
54
|
},
|
|
55
55
|
func: async ({ to, subject, body }: { to: string; subject: string; body: string }) => {
|
|
56
|
-
// Access env credentials set via crew.
|
|
56
|
+
// Access env credentials set via crew.crewState.set("env", {...})
|
|
57
57
|
const env = this.state.env || {};
|
|
58
58
|
const smtpHost = env.SMTP_HOST;
|
|
59
59
|
const smtpUser = env.SMTP_USER;
|
|
@@ -84,15 +84,15 @@ async function main() {
|
|
|
84
84
|
const crew = new AxCrew(config, functions);
|
|
85
85
|
|
|
86
86
|
// Set environment variables in shared state BEFORE adding agents
|
|
87
|
-
crew.
|
|
87
|
+
crew.crewState.set("env", {
|
|
88
88
|
SMTP_HOST: "smtp.example.com",
|
|
89
89
|
SMTP_USER: "user@example.com",
|
|
90
90
|
SMTP_PASS: "secret",
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
// You can also set arbitrary data
|
|
94
|
-
crew.
|
|
95
|
-
crew.
|
|
94
|
+
crew.crewState.set("company", "Acme Corp");
|
|
95
|
+
crew.crewState.set("maxRetries", 3);
|
|
96
96
|
|
|
97
97
|
await crew.addAllAgents();
|
|
98
98
|
const notifier = crew.agents?.get("notifier");
|
|
@@ -101,11 +101,11 @@ async function main() {
|
|
|
101
101
|
console.log(result?.result);
|
|
102
102
|
|
|
103
103
|
// Read state back
|
|
104
|
-
console.log("All state:", crew.
|
|
105
|
-
console.log("Company:", crew.
|
|
104
|
+
console.log("All state:", crew.crewState.getAll());
|
|
105
|
+
console.log("Company:", crew.crewState.get("company"));
|
|
106
106
|
|
|
107
107
|
// Reset state (clear all)
|
|
108
|
-
crew.
|
|
108
|
+
crew.crewState.reset();
|
|
109
109
|
|
|
110
110
|
crew.destroy();
|
|
111
111
|
}
|
|
@@ -118,7 +118,7 @@ main().catch(console.error);
|
|
|
118
118
|
The common pattern for passing credentials to class-based functions:
|
|
119
119
|
|
|
120
120
|
```ts
|
|
121
|
-
crew.
|
|
121
|
+
crew.crewState.set("env", {
|
|
122
122
|
WORDPRESS_URL: "http://my-wordpress-site.com",
|
|
123
123
|
WORDPRESS_USERNAME: "my-username",
|
|
124
124
|
WORDPRESS_PASSWORD: "my-password",
|
|
@@ -147,22 +147,25 @@ class MyFunction {
|
|
|
147
147
|
|
|
148
148
|
## Accessing State from Agents
|
|
149
149
|
|
|
150
|
-
Each `StatefulAxAgent` has a `
|
|
150
|
+
Each `StatefulAxAgent` has a `crewState` property that references the crew's shared state:
|
|
151
151
|
|
|
152
152
|
```ts
|
|
153
153
|
const agent = crew.agents?.get("myAgent");
|
|
154
|
-
// agent.
|
|
154
|
+
// agent.crewState is the same StateInstance as crew.crewState
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
+
## Supporting files
|
|
158
|
+
- See [examples/write-post-and-publish-to-wordpress.ts](examples/write-post-and-publish-to-wordpress.ts) for a complete runnable example.
|
|
159
|
+
|
|
157
160
|
## Do Not Generate
|
|
158
161
|
|
|
159
162
|
- Do NOT assume state values exist without checking; always use optional chaining (e.g. `this.state.env?.KEY`).
|
|
160
|
-
- Do NOT call `crew.
|
|
161
|
-
- Do NOT confuse `crew.
|
|
163
|
+
- Do NOT call `crew.crewState.set("env", ...)` after `addAllAgents()` if class-based functions read state during construction -- set state first.
|
|
164
|
+
- Do NOT confuse `crew.crewState` (StateInstance with `set`/`get`/`getAll`/`reset`) with plain objects. The state object passed to class-based function constructors is a plain record, not the `StateInstance` interface.
|
|
162
165
|
- Do NOT store sensitive credentials in state if the state object might be logged or serialized. The `getAll()` method returns all stored values.
|
|
163
166
|
|
|
164
167
|
## References
|
|
165
168
|
|
|
166
|
-
- [write-post-and-publish-to-wordpress.ts](
|
|
167
|
-
- [src/state/index.ts](
|
|
168
|
-
- [src/types.ts](
|
|
169
|
+
- [write-post-and-publish-to-wordpress.ts](examples/write-post-and-publish-to-wordpress.ts)
|
|
170
|
+
- [src/state/index.ts](src/state/index.ts)
|
|
171
|
+
- [src/types.ts](src/types.ts)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
version: "
|
|
2
|
+
name: axcrew-streaming
|
|
3
|
+
version: "8.7.3"
|
|
4
4
|
description: "ax-crew streaming patterns: streaming, streamingForward, stream, delta, real-time, chunks, async generator consumption"
|
|
5
5
|
argument-hint: [topic]
|
|
6
6
|
allowed-tools: Read, Grep, Glob
|
|
@@ -129,6 +129,9 @@ async function main() {
|
|
|
129
129
|
main().catch(console.error);
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
+
## Supporting files
|
|
133
|
+
- See [examples/streaming.ts](examples/streaming.ts) for a complete runnable example.
|
|
134
|
+
|
|
132
135
|
## Do Not Generate
|
|
133
136
|
|
|
134
137
|
- Do NOT `await` the return of `streamingForward()` -- it returns the async generator directly, not a promise.
|
|
@@ -139,5 +142,5 @@ main().catch(console.error);
|
|
|
139
142
|
|
|
140
143
|
## References
|
|
141
144
|
|
|
142
|
-
- [streaming.ts
|
|
143
|
-
- [Source: StatefulAxAgent.streamingForward](
|
|
145
|
+
- [streaming.ts](examples/streaming.ts)
|
|
146
|
+
- [Source: StatefulAxAgent.streamingForward](src/agents/index.ts)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: axcrew-sub-agents
|
|
3
3
|
description: AxCrew sub-agent composition via agents[] field. Covers agent delegation, dependency resolution, lazy agents (addLazyAgent), parent-child tool integration, and multi-agent orchestration patterns.
|
|
4
|
-
version: "
|
|
4
|
+
version: "8.7.3"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# AxCrew Sub-Agents
|
|
@@ -189,6 +189,10 @@ crew.addLazyAgent("RarelyUsedAgent");
|
|
|
189
189
|
|
|
190
190
|
The lazy agent exposes the same `getFunction()` interface. When the parent agent delegates to it, the real agent is created on-demand.
|
|
191
191
|
|
|
192
|
+
## Supporting files
|
|
193
|
+
- See [examples/basic-researcher-writer.ts](examples/basic-researcher-writer.ts) for simple delegation.
|
|
194
|
+
- See [examples/rlm-shared-fields.ts](examples/rlm-shared-fields.ts) for multi-agent with shared fields.
|
|
195
|
+
|
|
192
196
|
## Do Not Generate
|
|
193
197
|
|
|
194
198
|
- Do NOT list an agent in `agents[]` that is not defined in the crew config
|
|
@@ -199,5 +203,5 @@ The lazy agent exposes the same `getFunction()` interface. When the parent agent
|
|
|
199
203
|
|
|
200
204
|
## References
|
|
201
205
|
|
|
202
|
-
- [basic-researcher-writer.ts](
|
|
203
|
-
- [rlm-shared-fields.ts](
|
|
206
|
+
- [basic-researcher-writer.ts](examples/basic-researcher-writer.ts) -- simple delegation
|
|
207
|
+
- [rlm-shared-fields.ts](examples/rlm-shared-fields.ts) -- multi-agent with shared fields
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
version:
|
|
2
|
+
name: axcrew-telemetry
|
|
3
|
+
version: 8.7.3
|
|
4
4
|
description: "AxCrew telemetry: OpenTelemetry tracing, metrics, observability with tracer and meter injection."
|
|
5
5
|
tags: [telemetry, opentelemetry, tracing, metrics, observability, tracer, meter]
|
|
6
6
|
---
|
|
@@ -148,6 +148,9 @@ async function main() {
|
|
|
148
148
|
main().catch(console.error);
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
+
## Supporting files
|
|
152
|
+
- See [examples/telemetry-demo.ts](examples/telemetry-demo.ts) for a complete runnable example.
|
|
153
|
+
|
|
151
154
|
## Do Not Generate
|
|
152
155
|
|
|
153
156
|
- Do NOT import OpenTelemetry types from `ax-crew` -- import them from `@opentelemetry/api` and the SDK packages.
|
|
@@ -157,5 +160,5 @@ main().catch(console.error);
|
|
|
157
160
|
|
|
158
161
|
## References
|
|
159
162
|
|
|
160
|
-
- [telemetry-demo.ts](
|
|
163
|
+
- [telemetry-demo.ts](examples/telemetry-demo.ts)
|
|
161
164
|
- [OpenTelemetry JS](https://opentelemetry.io/docs/languages/js/)
|