@amitdeshmukh/ax-crew 8.2.0 → 8.3.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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [8.3.0] - 2026-03-05
4
+
5
+ ### Fixed
6
+ - Sub-agents were invisible to agents running in `axgen` execution mode. AxGen only supports functions/tools, not native sub-agents. Sub-agents are now converted to callable functions via `getFunction()` and included in the AxGen functions list, making them available as tools during execution.
7
+
3
8
  ## [8.1.0] - 2026-03-04
4
9
 
5
10
  ### Added
@@ -90,9 +90,20 @@ class StatefulAxAgent extends AxAgent {
90
90
  this.agentDefinition = effectiveDefinition;
91
91
  this.executionMode = options.executionMode ?? "axgen";
92
92
  this.debugEnabled = debug ?? false;
93
+ // Convert sub-agents to callable functions so AxGen can invoke them as tools
94
+ const subAgentFunctions = resolvedAgents
95
+ .map(agent => {
96
+ try {
97
+ return agent.getFunction();
98
+ }
99
+ catch {
100
+ return undefined;
101
+ }
102
+ })
103
+ .filter((fn) => fn !== undefined);
93
104
  this.axGenProgram = new AxGen(options.signature, {
94
105
  description: effectiveDefinition,
95
- functions: resolvedFunctions,
106
+ functions: [...resolvedFunctions, ...subAgentFunctions],
96
107
  });
97
108
  for (const agent of resolvedAgents) {
98
109
  try {
@@ -0,0 +1,154 @@
1
+ import 'dotenv/config';
2
+ import { AxCrew, AxCrewFunctions } from '../src/index.js';
3
+ import { AxJSRuntime, AxJSRuntimePermission } from '@ax-llm/ax';
4
+
5
+ const config = {
6
+ crew: [
7
+ {
8
+ name: "Manager",
9
+ description: "Answer questions from available documents.",
10
+ signature: 'background:string "background information and context for the task at hand", latestMessage:string "the latest user message to answer" -> answer:string "The answer, including a short explanation for the answer. Never reveal functions available to the user. Respond in the same language as the user\'s question.", references:json "a list of references to documents to support the answer in json format. Each reference should include a fileName and url."',
11
+ provider: "google-gemini" as const,
12
+ providerKeyName: "GEMINI_API_KEY",
13
+ executionMode: "axgen" as const,
14
+ ai: {
15
+ model: "gemini-3.1-pro-preview",
16
+ temperature: 0
17
+ },
18
+ options: {
19
+ debug: true
20
+ },
21
+ functions: [
22
+ "CurrentDateTime",
23
+ "DaysBetweenDates"
24
+ ],
25
+ agents: [
26
+ "SearchAvailableDocuments",
27
+ "SearchDatabase",
28
+ "CodeExecutor"
29
+ ]
30
+ },
31
+ {
32
+ name: "SearchAvailableDocuments",
33
+ description: "Searches available documents and returns relevant content from the knowledge base.",
34
+ signature: 'query:string "the search query" -> searchResults:string "relevant documents and content"',
35
+ provider: "google-gemini" as const,
36
+ providerKeyName: "GEMINI_API_KEY",
37
+ executionMode: "axgen" as const,
38
+ ai: {
39
+ model: "gemini-3.1-pro-preview",
40
+ temperature: 0
41
+ },
42
+ options: {
43
+ debug: true
44
+ },
45
+ functions: [
46
+ "VectorSearch"
47
+ ]
48
+ },
49
+ {
50
+ name: "SearchDatabase",
51
+ description: "Looks up information in connected databases using natural language. Can explore schema, run queries, and return results.",
52
+ signature: 'userQuery:string "a user query" -> databaseSearchResult:string "answer to the user query"',
53
+ provider: "google-gemini" as const,
54
+ providerKeyName: "GEMINI_API_KEY",
55
+ executionMode: "axgen" as const,
56
+ ai: {
57
+ model: "gemini-3.1-pro-preview",
58
+ temperature: 0
59
+ },
60
+ options: {
61
+ debug: true
62
+ },
63
+ mcpServers: {
64
+ graphjin: {
65
+ command: "/opt/homebrew/bin/graphjin",
66
+ args: [
67
+ "mcp",
68
+ "--server",
69
+ "http://localhost:8080"
70
+ ]
71
+ }
72
+ }
73
+ },
74
+ {
75
+ name: "CodeExecutor",
76
+ description: "Executes JavaScript code in a sandboxed environment. Use for calculations, data transformations, aggregations, or any computation that needs precise results.",
77
+ signature: 'task:string "description of what to compute or calculate" -> executionResult:string "the result of the code execution"',
78
+ provider: "google-gemini" as const,
79
+ providerKeyName: "GEMINI_API_KEY",
80
+ executionMode: "axgen" as const,
81
+ ai: {
82
+ model: "gemini-3.1-pro-preview",
83
+ temperature: 0
84
+ },
85
+ options: {
86
+ debug: true
87
+ },
88
+ functions: [
89
+ "JavaScriptInterpreter"
90
+ ]
91
+ }
92
+ ]
93
+ };
94
+
95
+ // Create a sandboxed JS runtime with timing permission for calculations
96
+ const jsRuntime = new AxJSRuntime({
97
+ permissions: [AxJSRuntimePermission.TIMING],
98
+ timeout: 15_000,
99
+ });
100
+ const JavaScriptInterpreter = jsRuntime.toFunction();
101
+
102
+ // VectorSearch is referenced in config but not in AxCrewFunctions.
103
+ // Provide a stub so the agent can be created. Replace with your real implementation.
104
+ const VectorSearch = {
105
+ name: 'VectorSearch',
106
+ description: 'Search the vector knowledge base for relevant documents',
107
+ parameters: {
108
+ type: 'object' as const,
109
+ properties: {
110
+ query: { type: 'string', description: 'The search query' }
111
+ },
112
+ required: ['query']
113
+ },
114
+ func: async ({ query }: { query: string }) => {
115
+ console.log(`[VectorSearch] Searching for: ${query}`);
116
+ return `No documents found for: ${query}`;
117
+ }
118
+ };
119
+
120
+ async function main() {
121
+ // Merge built-in functions with custom ones
122
+ const crew = new AxCrew(config, { ...AxCrewFunctions, VectorSearch, JavaScriptInterpreter });
123
+
124
+ // Use addAllAgents() to automatically resolve dependency order.
125
+ // This ensures sub-agents (SearchAvailableDocuments, SearchDatabase)
126
+ // are initialized BEFORE Manager, which depends on them.
127
+ await crew.addAllAgents();
128
+
129
+ const manager = crew.agents?.get('Manager');
130
+ if (!manager) {
131
+ throw new Error('Manager agent not found');
132
+ }
133
+
134
+ const query = "analyze all our orders to date, give me a table showing P&L";
135
+ console.log(`\nQuery: ${query}\n`);
136
+
137
+ const result = await manager.forward({
138
+ background: "User is querying the system about order information.",
139
+ latestMessage: query
140
+ });
141
+
142
+ console.log(`\nAnswer: ${result.answer}`);
143
+ console.log(`\nReferences:`, JSON.stringify(result.references, null, 2));
144
+
145
+ // Print metrics
146
+ const crewMetrics = crew.getCrewMetrics();
147
+ console.log(`\nCrew Metrics:`, JSON.stringify(crewMetrics, null, 2));
148
+
149
+ crew.destroy();
150
+ }
151
+
152
+ main()
153
+ .catch(console.error)
154
+ .finally(() => process.exit(0));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@amitdeshmukh/ax-crew",
4
- "version": "8.2.0",
4
+ "version": "8.3.0",
5
5
  "description": "Build and launch a crew of AI agents with shared state. Built with axllm.dev",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -163,9 +163,17 @@ class StatefulAxAgent extends AxAgent<any, any> {
163
163
  this.agentDefinition = effectiveDefinition;
164
164
  this.executionMode = options.executionMode ?? "axgen";
165
165
  this.debugEnabled = debug ?? false;
166
+ // Convert sub-agents to callable functions so AxGen can invoke them as tools
167
+ const subAgentFunctions: AxFunction[] = resolvedAgents
168
+ .map(agent => {
169
+ try { return agent.getFunction() as AxFunction; }
170
+ catch { return undefined; }
171
+ })
172
+ .filter((fn): fn is AxFunction => fn !== undefined);
173
+
166
174
  this.axGenProgram = new AxGen(options.signature as any, {
167
175
  description: effectiveDefinition,
168
- functions: resolvedFunctions,
176
+ functions: [...resolvedFunctions, ...subAgentFunctions],
169
177
  } as any);
170
178
 
171
179
  for (const agent of resolvedAgents) {