@devries-cameron20 / composio Mirror · read-only / commits / ee34cd31b
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 00:45 UTC

chore: rename to experimental_subAgent (#3053)

Rahul Tarak committed Mar 27, 2026 at 06:32 UTC ee34cd31ba74e02b71381e71a7f0c2500141783a
10 files changed +70 -65
ts/packages/cli/skills/composio-cli/SKILL.md
+2 -2
@@ -80,7 +80,7 @@ composio proxy https://api.github.com/user --toolkit github --method GET </dev/n
80
81 > **For programmatic calls, LLM workflows, or anything beyond a single tool call — use `composio run`.**
82
83 -`composio run` executes an inline JavaScript snippet with authenticated `execute()`, `search()`, `proxy()`, and `subAgent()` helpers pre-injected. No SDK setup required.
83 +`composio run` executes an inline JavaScript snippet with authenticated `execute()`, `search()`, `proxy()`, and the experimental `experimental_subAgent()` helper pre-injected. No SDK setup required.
84
85 Chain multiple tools:
86
@@ -111,7 +111,7 @@ Feed tool output into an LLM and get structured JSON back:
111 ```bash
112 composio run --logs-off '
113 const emails = await execute("GMAIL_FETCH_EMAILS", { max_results: 5 });
114 - const brief = await subAgent(
114 + const brief = await experimental_subAgent(
115 `Summarize these emails and count them.\n\n${emails.prompt()}`,
116 { schema: z.object({ summary: z.string(), count: z.number() }) }
117 );
ts/packages/cli/skills/composio-cli/references/power-user-examples.md
+5 -5
@@ -1,6 +1,6 @@
1 # Power-User Examples
2
3 -Load this file when the user needs more than one top-level command, wants to script workflows, or wants to use `subAgent()` inside `composio run`.
3 +Load this file when the user needs more than one top-level command, wants to script workflows, or wants to use `experimental_subAgent()` inside `composio run`.
4
5 ## Use `run` To Chain Tool Calls
6
@@ -72,7 +72,7 @@ Batch related discovery work with multiple queries when it keeps the workflow si
72 composio search "send an email" "create a github issue" --toolkits gmail,github
73 ```
74
75 -## Use `subAgent()` With `z` And `result.prompt()`
75 +## Use `experimental_subAgent()` With `z` And `result.prompt()`
76
77 Turn a tool result into structured output:
78
@@ -80,7 +80,7 @@ Turn a tool result into structured output:
80 composio run --logs-off '
81 const emails = await execute("GMAIL_FETCH_EMAILS", { max_results: 2 });
82
83 - const brief = await subAgent(
83 + const brief = await experimental_subAgent(
84 `Return only valid JSON matching the schema. Summarize these emails in one sentence and report how many items were returned.\n\n${emails.prompt()}`,
85 {
86 schema: z.object({
@@ -94,7 +94,7 @@ composio run --logs-off '
94 '
95 ```
96
97 -Use `result.prompt()` when the helper result is too noisy for a raw object dump but you still want to feed it into `subAgent()`.
97 +Use `result.prompt()` when the helper result is too noisy for a raw object dump but you still want to feed it into `experimental_subAgent()`.
98
99 ## Use `proxy()` For Raw API Access
100
@@ -130,7 +130,7 @@ composio run '
130
131 - Use `--dry-run` to preview every `execute()` call in the script.
132 - Use `--debug` to see helper steps while the script runs.
133 -- Use `--logs-off` when `subAgent()` streaming logs are too noisy for the task.
133 +- Use `--logs-off` when `experimental_subAgent()` streaming logs are too noisy for the task.
134
135 Example:
136
ts/packages/cli/src/commands/install.cmd.ts
+6 -4
@@ -191,13 +191,13 @@ export const installShellIntegration = (params: {
191 yield* ui.log.step('PATH: already configured');
192 }
193
194 - if (shell === 'zsh') {
194 + if (params.noCompletions) {
195 + yield* ui.log.step('Completions: skipped (--no-completions)');
196 + } else if (shell === 'zsh') {
197 yield* ui.log.step('Completions: skipped for zsh');
198 } else if (config.completionBlock && !fileContains(existing, COMPLETIONS_MARKER)) {
199 blocks.push(config.completionBlock);
200 yield* ui.log.step('Completions: will install shell completions');
199 - } else if (params.noCompletions) {
200 - yield* ui.log.step('Completions: skipped (--no-completions)');
201 } else if (!config.completionBlock) {
202 yield* ui.log.step('Completions: not available for this shell');
203 } else {
@@ -224,7 +224,9 @@ export const installShellIntegration = (params: {
224
225 yield* ui.log.success(`Updated ${tildify(rcPath, os.homedir)}`);
226 yield* ui.note(
227 - shell === 'fish' || shell === 'zsh' ? `source ${tildify(rcPath, os.homedir)}` : 'exec $SHELL',
227 + shell === 'fish' || shell === 'zsh'
228 + ? `source ${tildify(rcPath, os.homedir)}`
229 + : 'exec $SHELL',
230 'Restart your shell to apply changes'
231 );
232 } else {
ts/packages/cli/src/commands/root-help.ts
+7 -7
@@ -60,7 +60,7 @@ const CORE_COMMANDS: ReadonlyArray<DetailedCommand> = [
60 {
61 name: 'run',
62 description:
63 - 'Run inline TS/JS code with shimmed CLI commands; injected execute(), search(), proxy(), subAgent(), and z (zod).',
63 + 'Run inline TS/JS code with shimmed CLI commands; injected execute(), search(), proxy(), experimental_subAgent(), and z (zod).',
64 usage: 'run <code> [-- ...args] | run [-f, --file text] [-- ...args] [--dry-run]',
65 options: [
66 { name: '<code>', description: 'Inline Bun ESNext code to evaluate' },
@@ -281,7 +281,7 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp> = {
281 { name: '-f, --file <text>', description: 'Run a TS/JS file instead of inline code' },
282 { name: '--dry-run', description: 'Preview execute() calls without running them' },
283 { name: '--debug', description: 'Log helper steps while the script runs' },
284 - { name: '--logs-off', description: 'Hide the always-on subAgent streaming logs' },
284 + { name: '--logs-off', description: 'Hide the always-on experimental_subAgent streaming logs' },
285 ],
286 flags: [
287 { name: '--skip-connection-check', description: 'Skip the connected-account check' },
@@ -299,8 +299,8 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp> = {
299 { name: 'search(query, opts?)', description: 'Find tools — same as `composio search`' },
300 { name: 'proxy(toolkit)', description: 'Returns a fetch() bound to your connected account' },
301 {
302 - name: 'subAgent(prompt, opts?)',
303 - description: 'Spawn a sub-agent (Claude/Codex) with optional structured output',
302 + name: 'experimental_subAgent(prompt, opts?)',
303 + description: 'Experimental sub-agent helper (Claude/Codex) with optional structured output',
304 },
305 {
306 name: 'result.prompt()',
@@ -351,7 +351,7 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp> = {
351 ` console.log(await f("https://gmail.googleapis.com/gmail/v1/users/me/profile"));`,
352 `'`,
353 '',
354 - '# subAgent + z + result.prompt() — structured output from a sub-agent',
354 + '# experimental_subAgent + z + result.prompt() — structured output from a sub-agent',
355 `composio run '`,
356 ` const [emails, issues] = await Promise.all([`,
357 ` execute("GMAIL_FETCH_EMAILS", { max_results: 5 }),`,
@@ -359,7 +359,7 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp> = {
359 ` ]);`,
360 ` // result.prompt() serializes helper output for LLM consumption`,
361 ` // z is a global from zod for defining structured output schemas`,
362 - ` const brief = await subAgent(`,
362 + ` const brief = await experimental_subAgent(`,
363 ` \`Summarize these emails and issues.\\n\\n\${emails.prompt()}\\n\\n\${issues.prompt()}\`,`,
364 ` { schema: z.object({ summary: z.string(), urgent: z.array(z.string()) }) }`,
365 ` );`,
@@ -984,7 +984,7 @@ export function printRootHelp(): Effect.Effect<void> {
984 ` execute("GMAIL_FETCH_EMAILS", { max_results: 5 }),`,
985 ` execute("GITHUB_LIST_REPOSITORY_ISSUES", { owner: "acme", repo: "app", state: "open" }),`,
986 ` ]);`,
987 - ` const brief = await subAgent(\`Summarize:\\n\${emails.prompt()}\\n\${issues.prompt()}\`);`,
987 + ` const brief = await experimental_subAgent(\`Summarize:\\n\${emails.prompt()}\\n\${issues.prompt()}\`);`,
988 ` console.log(brief);`,
989 ` '`,
990 '',
ts/packages/cli/src/commands/run.cmd.ts
+30 -30
@@ -232,9 +232,9 @@ const buildRunBaseHelpersSource = (): ReadonlyArray<string> => [
232 'let perfDebugSeq = 0;',
233 'const proxySessionCache = new Map();',
234 'const composioBaseURL = (helperContext.baseURL || "https://backend.composio.dev").replace(/\\/$/, "");',
235 - 'const subAgentSchema = {',
235 + 'const experimentalSubAgentSchema = {',
236 ' type: "function",',
237 - ' description: "Prompt a sub-agent from the same agent family as the current main agent (Codex -> Codex, Claude -> Claude) and return its final response.",',
237 + ' description: "Experimental helper: prompt a sub-agent from the same agent family as the current main agent (Codex -> Codex, Claude -> Claude) and return its final response.",',
238 ' parameters: {',
239 ' type: "object",',
240 ' additionalProperties: false,',
@@ -320,42 +320,42 @@ const buildRunBaseHelpersSource = (): ReadonlyArray<string> => [
320 'const formatHelperDebugEvent = (step, details = {}) => {',
321 ' switch (step) {',
322 ' case "subAgent.target":',
323 - ' return `[subAgent] triggered with ${details.resolvedTarget}`;',
323 + ' return `[experimental_subAgent] triggered with ${details.resolvedTarget}`;',
324 ' case "subAgent.acp.resolve":',
325 - ' return `[subAgent] ACP via ${details.source} (${details.target})`;',
325 + ' return `[experimental_subAgent] ACP via ${details.source} (${details.target})`;',
326 ' case "subAgent.acp.initialized":',
327 - ' return `[subAgent] ACP initialized (${details.target})`;',
327 + ' return `[experimental_subAgent] ACP initialized (${details.target})`;',
328 ' case "subAgent.acp.session":',
329 - ' return `[subAgent] session ready (${details.target})`;',
329 + ' return `[experimental_subAgent] session ready (${details.target})`;',
330 ' case "subAgent.acp.model":',
331 ' return details.applied === true',
332 - ' ? `[subAgent] model=${details.model}`',
333 - ' : `[subAgent] model unchanged (${details.model})`;',
332 + ' ? `[experimental_subAgent] model=${details.model}`',
333 + ' : `[experimental_subAgent] model unchanged (${details.model})`;',
334 ' case "subAgent.acp.message": {',
335 ' const text = previewDebugValue(details.text);',
336 - ' return text ? `[subAgent] ${text}` : null;',
336 + ' return text ? `[experimental_subAgent] ${text}` : null;',
337 ' }',
338 ' case "subAgent.acp.thought": {',
339 ' const text = previewDebugValue(details.text);',
340 - ' return text ? `[subAgent:thinking] ${text}` : null;',
340 + ' return text ? `[experimental_subAgent:thinking] ${text}` : null;',
341 ' }',
342 ' case "subAgent.acp.tool_call": {',
343 ' const where = Array.isArray(details.locations) && details.locations.length > 0 ? ` ${details.locations.slice(0, 2).join(", ")}` : "";',
344 - ' return `[subAgent:tool] ${details.status || "pending"} ${details.title || details.kind || "tool"}${where}`;',
344 + ' return `[experimental_subAgent:tool] ${details.status || "pending"} ${details.title || details.kind || "tool"}${where}`;',
345 ' }',
346 ' case "subAgent.acp.tool_call_update": {',
347 ' const where = Array.isArray(details.locations) && details.locations.length > 0 ? ` ${details.locations.slice(0, 2).join(", ")}` : "";',
348 ' const preview = previewDebugValue(details.rawOutput);',
349 - ' return `[subAgent:tool] ${details.status || "update"} ${details.title || details.toolCallId || details.kind || "tool"}${where}${preview ? ` -> ${preview}` : ""}`;',
349 + ' return `[experimental_subAgent:tool] ${details.status || "update"} ${details.title || details.toolCallId || details.kind || "tool"}${where}${preview ? ` -> ${preview}` : ""}`;',
350 ' }',
351 ' case "subAgent.acp.plan": {',
352 ' const entries = Array.isArray(details.entries) ? details.entries : [];',
353 - ' if (entries.length === 0) return "[subAgent:plan] updated";',
353 + ' if (entries.length === 0) return "[experimental_subAgent:plan] updated";',
354 ' const summary = entries.slice(0, 3).map((entry) => `${entry.status}:${truncateDebugText(entry.content || "", 48)}`).join(" | ");',
355 - ' return `[subAgent:plan] ${summary}`;',
355 + ' return `[experimental_subAgent:plan] ${summary}`;',
356 ' }',
357 ' case "subAgent.acp.fallback":',
358 - ' return `[subAgent] ACP fallback (${details.code})`;',
358 + ' return `[experimental_subAgent] ACP fallback (${details.code})`;',
359 ' case "execute.prepare":',
360 ' return `[execute] ${details.slug}`;',
361 ' case "search.prepare":',
@@ -471,14 +471,14 @@ const buildRunBaseHelpersSource = (): ReadonlyArray<string> => [
471 ' if (detected === "codex" || detected === "claude") return detected;',
472 ' if (typeof Bun.which === "function" && Bun.which("codex")) return "codex";',
473 ' if (typeof Bun.which === "function" && Bun.which("claude")) return "claude";',
474 - ' throw new Error("subAgent() could not determine an agent CLI. Current master is user; install codex or claude, or pass { target: \\"codex\\" | \\"claude\\" }.");',
474 + ' throw new Error("experimental_subAgent() could not determine an agent CLI. Current master is user; install codex or claude, or pass { target: \\"codex\\" | \\"claude\\" }.");',
475 '};',
476 'const normalizeInvokeAgentOptions = (options = {}) => {',
477 ' if (options == null || typeof options !== "object" || Array.isArray(options)) {',
478 - ' throw new Error("subAgent() options must be an object when provided.");',
478 + ' throw new Error("experimental_subAgent() options must be an object when provided.");',
479 ' }',
480 ' if (options.schema !== undefined && options.jsonSchema !== undefined) {',
481 - ' throw new Error("subAgent() accepts either options.schema or options.jsonSchema, not both.");',
481 + ' throw new Error("experimental_subAgent() accepts either options.schema or options.jsonSchema, not both.");',
482 ' }',
483 ' const inputSchema = options.schema ?? options.jsonSchema;',
484 ' let structuredSchema;',
@@ -486,14 +486,14 @@ const buildRunBaseHelpersSource = (): ReadonlyArray<string> => [
486 ' if (inputSchema !== undefined) {',
487 ' if (inputSchema && typeof inputSchema.safeParse === "function" && inputSchema._def) {',
488 ' if (typeof z.toJSONSchema !== "function") {',
489 - ' throw new Error("subAgent() requires Zod 4 with z.toJSONSchema() when using options.schema.");',
489 + ' throw new Error("experimental_subAgent() requires Zod 4 with z.toJSONSchema() when using options.schema.");',
490 ' }',
491 ' zodSchema = inputSchema;',
492 ' structuredSchema = z.toJSONSchema(inputSchema);',
493 ' } else if (typeof inputSchema === "object" && inputSchema !== null && !Array.isArray(inputSchema)) {',
494 ' structuredSchema = inputSchema;',
495 ' } else {',
496 - ' throw new Error("subAgent() schema must be a Zod schema or JSON Schema object.");',
496 + ' throw new Error("experimental_subAgent() schema must be a Zod schema or JSON Schema object.");',
497 ' }',
498 ' }',
499 ' return { ...options, structuredSchema, zodSchema };',
@@ -694,9 +694,9 @@ const buildRunBaseHelpersSource = (): ReadonlyArray<string> => [
694 ];
695
696 const buildRunInvokeAgentHelpersSource = (): ReadonlyArray<string> => [
697 - 'const subAgentImpl = async (prompt, options = {}) => {',
697 + 'const experimentalSubAgentImpl = async (prompt, options = {}) => {',
698 ' if (typeof prompt !== "string" || prompt.trim().length === 0) {',
699 - ' throw new Error("subAgent() requires a non-empty prompt string.");',
699 + ' throw new Error("experimental_subAgent() requires a non-empty prompt string.");',
700 ' }',
701 ' const logFilePath = typeof helperContext.runLogFilePath === "string" && helperContext.runLogFilePath.length > 0 ? helperContext.runLogFilePath : undefined;',
702 ' const normalizedOptions = normalizeInvokeAgentOptions(options);',
@@ -732,10 +732,10 @@ const buildRunInvokeAgentHelpersSource = (): ReadonlyArray<string> => [
732 ' return logFilePath ? { ...response, logFilePath } : response;',
733 ' }',
734 '};',
735 - 'globalThis.subAgent = subAgentImpl;',
736 - 'Object.defineProperty(globalThis.subAgent, "schema", { value: subAgentSchema });',
737 - 'globalThis.invokeAgent = subAgentImpl;',
738 - 'Object.defineProperty(globalThis.invokeAgent, "schema", { value: subAgentSchema });',
735 + 'globalThis.experimental_subAgent = experimentalSubAgentImpl;',
736 + 'Object.defineProperty(globalThis.experimental_subAgent, "schema", { value: experimentalSubAgentSchema });',
737 + 'globalThis.invokeAgent = experimentalSubAgentImpl;',
738 + 'Object.defineProperty(globalThis.invokeAgent, "schema", { value: experimentalSubAgentSchema });',
739 '',
740 ];
741
@@ -995,7 +995,7 @@ export const runCmd = Command.make('run', {
995 ` execute("GMAIL_FETCH_EMAILS", { max_results: 5 }),`,
996 ` execute("GITHUB_LIST_REPOSITORY_ISSUES", { owner: "composiohq", repo: "composio", state: "open" }),`,
997 ` ]);`,
998 - ` const brief = await subAgent(`,
998 + ` const brief = await experimental_subAgent(`,
999 ` \`Create a morning brief from these emails and issues.\\n\\n\${emails.prompt()}\\n\\n\${issues.prompt()}\`,`,
1000 ` {`,
1001 ` schema: z.object({`,
@@ -1012,9 +1012,9 @@ export const runCmd = Command.make('run', {
1012 'Injected helpers (behave like their CLI counterparts):',
1013 ' execute(slug, data?) Same as `composio execute` — returns parsed JSON',
1014 ' search(query, options?) Same as `composio search` — returns matching tools',
1015 - ' subAgent(prompt, options?) Spawn a powerful sub-agent from the same agent family as your current main agent',
1015 + ' experimental_subAgent(prompt, options?) Experimental helper to spawn a powerful sub-agent from the same agent family as your current main agent',
1016 ' (Codex -> Codex, Claude -> Claude) with optional Zod structured output',
1017 - ' result.prompt() Prompt-safe serialization of a helper result, ideal for subAgent(...)',
1017 + ' result.prompt() Prompt-safe serialization of a helper result, ideal for experimental_subAgent(...)',
1018 ' const f = await proxy(toolkit) Same as `composio proxy` — returns a fetch function',
1019 ' Example: const f = await proxy("gmail")',
1020 ' const me = await f("https://gmail.googleapis.com/gmail/v1/users/me/profile")',
@@ -1025,7 +1025,7 @@ export const runCmd = Command.make('run', {
1025 'Flags:',
1026 ' --debug Log helper steps while the script runs',
1027 ' --dry-run Preview execute() calls without running them',
1028 - ' --logs-off Hide the always-on subAgent streaming logs',
1028 + ' --logs-off Hide the always-on experimental_subAgent streaming logs',
1029 ' --skip-connection-check Skip the connected-account check',
1030 ' --skip-tool-params-check Skip input validation against cached schema',
1031 ' --skip-checks Skip both checks above',
ts/packages/cli/src/services/project-environment-detector.ts
+4 -1
@@ -431,7 +431,10 @@ const detectLanguage = (fs: FileSystem.FileSystem, cwd: string) =>
431 if (evidence.strongPy)
432 return { language: 'python' as const, rootDir: dir, evidence } as const;
433
434 - const weakCandidate = pickBestWeak(evidence, depth);
434 + // Only allow weak detection at the requested cwd. Walking weak signals up
435 + // arbitrary ancestor directories causes false positives in temp dirs and
436 + // other shared parent paths outside the actual project.
437 + const weakCandidate = depth === 0 ? pickBestWeak(evidence, depth) : null;
438 if (weakCandidate && (!bestWeak || weakCandidate.score > bestWeak.score))
439 bestWeak = weakCandidate;
440 }
ts/packages/cli/src/services/run-subagent-legacy.ts
+1 -2
@@ -4,7 +4,6 @@ import * as path from 'node:path';
4 import { spawn } from 'node:child_process';
5 import type { MasterKind } from 'src/services/master-detector';
6 import {
7 - finalizeInvokeAgentText,
7 parseJson,
8 toInvokeAgentResponse,
9 type HelperDebugLog,
@@ -85,7 +84,7 @@ const invokeClaudeLegacy = async (
84 const result = await runExternalCommandText(args, helperDebugLog);
85 const parsed = parseJson(result.stdout.trim());
86 if (!parsed || typeof parsed !== 'object') {
88 - throw new Error('claude returned non-JSON output in subAgent().');
87 + throw new Error('claude returned non-JSON output in experimental_subAgent().');
88 }
89
90 const payload =
ts/packages/cli/src/services/run-subagent-output-mcp.ts
+1 -1
@@ -79,7 +79,7 @@ const main = async (): Promise<void> => {
79 {
80 title: 'Submit structured output',
81 description:
82 - 'Submit the final structured subAgent output. Call this exactly once when the task is complete.',
82 + 'Submit the final structured experimental_subAgent output. Call this exactly once when the task is complete.',
83 inputSchema: toolInputSchema,
84 },
85 async (payload: unknown) => {
ts/packages/cli/src/services/run-subagent-shared.ts
+3 -4
@@ -223,7 +223,7 @@ export const validateStructuredOutput = (
223 const validation = options.zodSchema.safeParse(parsed);
224 if (!validation.success) {
225 throw new Error(
226 - `subAgent() structured output failed schema validation: ${summarizeValidationError(validation.error)}`
226 + `experimental_subAgent() structured output failed schema validation: ${summarizeValidationError(validation.error)}`
227 );
228 }
229
@@ -373,10 +373,9 @@ export const finalizeInvokeAgentText = (
373 };
374 }
375
376 - let parsed: unknown;
377 - parsed = tryParseStructuredJson(trimmed);
376 + const parsed = tryParseStructuredJson(trimmed);
377 if (parsed === undefined) {
379 - throw new Error('subAgent() expected valid JSON output for structured response.');
378 + throw new Error('experimental_subAgent() expected valid JSON output for structured response.');
379 }
380
381 return {
ts/packages/cli/test/src/commands/run.cmd.test.ts
+11 -9
@@ -170,7 +170,7 @@ describe('CLI: composio run', () => {
170
171 layer(TestLive())(it => {
172 it.scoped(
173 - '[Given] run help [Then] it documents injected execute, search, proxy, subAgent, and z helpers',
173 + '[Given] run help [Then] it documents injected execute, search, proxy, experimental_subAgent, and z helpers',
174 () =>
175 Effect.gen(function* () {
176 yield* cli(['run', '--help']);
@@ -183,7 +183,7 @@ describe('CLI: composio run', () => {
183 expect(output).toContain('--skip-tool-params-check');
184 expect(output).toContain('--skip-checks');
185 expect(output).toContain('--logs-off');
186 - expect(output).toContain('subAgent');
186 + expect(output).toContain('experimental_subAgent');
187 expect(output).toContain('schema: z.object');
188 expect(output).toContain('INJECTED HELPERS');
189 expect(output).toContain('Global from zod');
@@ -234,7 +234,9 @@ describe('buildRunHelpersSource', () => {
234 expect(source).toContain('storedInFilePath: outputFilePath !== null,');
235 expect(source).toContain('outputFilePath,');
236 expect(source).toContain('const formatHelperDebugEvent = (step, details = {}) => {');
237 - expect(source).toContain('return `[subAgent] triggered with ${details.resolvedTarget}`;');
237 + expect(source).toContain(
238 + 'return `[experimental_subAgent] triggered with ${details.resolvedTarget}`;'
239 + );
240 expect(source).toContain('const logCliResultPreview = (requestId, command, result) => {');
241 expect(source).toContain('helperDebugLog("cli.result", {');
242 expect(source).toContain('helperDebugLog("cli.result.stored_in_file"');
@@ -251,11 +253,11 @@ describe('buildRunHelpersSource', () => {
253 'if (result && typeof result === "object" && result.successful === false) {'
254 );
255 expect(source).toContain('Object.assign(error, { result, slug });');
254 - expect(source).toContain('globalThis.subAgent = subAgentImpl;');
256 + expect(source).toContain('globalThis.experimental_subAgent = experimentalSubAgentImpl;');
257 expect(source).toContain(
256 - 'Object.defineProperty(globalThis.subAgent, "schema", { value: subAgentSchema });'
258 + 'Object.defineProperty(globalThis.experimental_subAgent, "schema", { value: experimentalSubAgentSchema });'
259 );
258 - expect(source).toContain('globalThis.invokeAgent = subAgentImpl;');
260 + expect(source).toContain('globalThis.invokeAgent = experimentalSubAgentImpl;');
261 expect(source).toContain(
262 'const logFilePath = typeof helperContext.runLogFilePath === "string"'
263 );
@@ -267,12 +269,12 @@ describe('buildRunHelpersSource', () => {
269 expect(source).toContain('const response = await invokeLegacySubAgent({');
270 expect(source).toContain('const detectInvokeAgentMaster = () => {');
271 expect(source).toContain(
270 - 'throw new Error("subAgent() accepts either options.schema or options.jsonSchema, not both.");'
272 + 'throw new Error("experimental_subAgent() accepts either options.schema or options.jsonSchema, not both.");'
273 );
274 expect(source).toContain('const inputSchema = options.schema ?? options.jsonSchema;');
275 expect(source).toContain('if (typeof z.toJSONSchema !== "function") {');
276 expect(source).toContain(
275 - 'subAgent() requires Zod 4 with z.toJSONSchema() when using options.schema.'
277 + 'experimental_subAgent() requires Zod 4 with z.toJSONSchema() when using options.schema.'
278 );
279 expect(source).toContain('let zodSchema;');
280 expect(source).toContain('zodSchema = inputSchema;');
@@ -366,7 +368,7 @@ describe('run-subagent-shared', () => {
368 finalizeInvokeAgentText('not-json', {
369 structuredSchema: { type: 'object' },
370 })
369 - ).toThrow('subAgent() expected valid JSON output for structured response.');
371 + ).toThrow('experimental_subAgent() expected valid JSON output for structured response.');
372 });
373
374 it('[Given] prose followed by JSON in structured mode [Then] it recovers the final JSON payload', () => {