Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
chore: rename to experimental_subAgent (#3053)
Rahul Tarakee34cd31ba74
diff --git a/ts/packages/cli/skills/composio-cli/SKILL.md b/ts/packages/cli/skills/composio-cli/SKILL.mdindex 2265dc423..d67830744 100644--- a/ts/packages/cli/skills/composio-cli/SKILL.md+++ b/ts/packages/cli/skills/composio-cli/SKILL.md@@ -80,7 +80,7 @@ composio proxy https://api.github.com/user --toolkit github --method GET </dev/n> **For programmatic calls, LLM workflows, or anything beyond a single tool call — use `composio run`.**-`composio run` executes an inline JavaScript snippet with authenticated `execute()`, `search()`, `proxy()`, and `subAgent()` helpers pre-injected. No SDK setup required.+`composio run` executes an inline JavaScript snippet with authenticated `execute()`, `search()`, `proxy()`, and the experimental `experimental_subAgent()` helper pre-injected. No SDK setup required.Chain multiple tools:@@ -111,7 +111,7 @@ Feed tool output into an LLM and get structured JSON back:```bashcomposio run --logs-off 'const emails = await execute("GMAIL_FETCH_EMAILS", { max_results: 5 });- const brief = await subAgent(+ const brief = await experimental_subAgent(`Summarize these emails and count them.\n\n${emails.prompt()}`,{ schema: z.object({ summary: z.string(), count: z.number() }) });diff --git a/ts/packages/cli/skills/composio-cli/references/power-user-examples.md b/ts/packages/cli/skills/composio-cli/references/power-user-examples.mdindex 690a30fce..44b5b2726 100644--- a/ts/packages/cli/skills/composio-cli/references/power-user-examples.md+++ b/ts/packages/cli/skills/composio-cli/references/power-user-examples.md@@ -1,6 +1,6 @@# Power-User Examples-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`.+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`.## Use `run` To Chain Tool Calls@@ -72,7 +72,7 @@ Batch related discovery work with multiple queries when it keeps the workflow sicomposio search "send an email" "create a github issue" --toolkits gmail,github```-## Use `subAgent()` With `z` And `result.prompt()`+## Use `experimental_subAgent()` With `z` And `result.prompt()`Turn a tool result into structured output:@@ -80,7 +80,7 @@ Turn a tool result into structured output:composio run --logs-off 'const emails = await execute("GMAIL_FETCH_EMAILS", { max_results: 2 });- const brief = await subAgent(+ const brief = await experimental_subAgent(`Return only valid JSON matching the schema. Summarize these emails in one sentence and report how many items were returned.\n\n${emails.prompt()}`,{schema: z.object({@@ -94,7 +94,7 @@ composio run --logs-off ''```-Use `result.prompt()` when the helper result is too noisy for a raw object dump but you still want to feed it into `subAgent()`.+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()`.## Use `proxy()` For Raw API Access@@ -130,7 +130,7 @@ composio run '- Use `--dry-run` to preview every `execute()` call in the script.- Use `--debug` to see helper steps while the script runs.-- Use `--logs-off` when `subAgent()` streaming logs are too noisy for the task.+- Use `--logs-off` when `experimental_subAgent()` streaming logs are too noisy for the task.Example:diff --git a/ts/packages/cli/src/commands/install.cmd.ts b/ts/packages/cli/src/commands/install.cmd.tsindex b8e6f5a63..3053523b8 100644--- a/ts/packages/cli/src/commands/install.cmd.ts+++ b/ts/packages/cli/src/commands/install.cmd.ts@@ -191,13 +191,13 @@ export const installShellIntegration = (params: {yield* ui.log.step('PATH: already configured');}- if (shell === 'zsh') {+ if (params.noCompletions) {+ yield* ui.log.step('Completions: skipped (--no-completions)');+ } else if (shell === 'zsh') {yield* ui.log.step('Completions: skipped for zsh');} else if (config.completionBlock && !fileContains(existing, COMPLETIONS_MARKER)) {blocks.push(config.completionBlock);yield* ui.log.step('Completions: will install shell completions');- } else if (params.noCompletions) {- yield* ui.log.step('Completions: skipped (--no-completions)');} else if (!config.completionBlock) {yield* ui.log.step('Completions: not available for this shell');} else {@@ -224,7 +224,9 @@ export const installShellIntegration = (params: {yield* ui.log.success(`Updated ${tildify(rcPath, os.homedir)}`);yield* ui.note(- shell === 'fish' || shell === 'zsh' ? `source ${tildify(rcPath, os.homedir)}` : 'exec $SHELL',+ shell === 'fish' || shell === 'zsh'+ ? `source ${tildify(rcPath, os.homedir)}`+ : 'exec $SHELL','Restart your shell to apply changes');} else {diff --git a/ts/packages/cli/src/commands/root-help.ts b/ts/packages/cli/src/commands/root-help.tsindex daf567c0d..3f96ed44e 100644--- a/ts/packages/cli/src/commands/root-help.ts+++ b/ts/packages/cli/src/commands/root-help.ts@@ -60,7 +60,7 @@ const CORE_COMMANDS: ReadonlyArray<DetailedCommand> = [{name: 'run',description:- 'Run inline TS/JS code with shimmed CLI commands; injected execute(), search(), proxy(), subAgent(), and z (zod).',+ 'Run inline TS/JS code with shimmed CLI commands; injected execute(), search(), proxy(), experimental_subAgent(), and z (zod).',usage: 'run <code> [-- ...args] | run [-f, --file text] [-- ...args] [--dry-run]',options: [{ name: '<code>', description: 'Inline Bun ESNext code to evaluate' },@@ -281,7 +281,7 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp> = {{ name: '-f, --file <text>', description: 'Run a TS/JS file instead of inline code' },{ name: '--dry-run', description: 'Preview execute() calls without running them' },{ name: '--debug', description: 'Log helper steps while the script runs' },- { name: '--logs-off', description: 'Hide the always-on subAgent streaming logs' },+ { name: '--logs-off', description: 'Hide the always-on experimental_subAgent streaming logs' },],flags: [{ name: '--skip-connection-check', description: 'Skip the connected-account check' },@@ -299,8 +299,8 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp> = {{ name: 'search(query, opts?)', description: 'Find tools — same as `composio search`' },{ name: 'proxy(toolkit)', description: 'Returns a fetch() bound to your connected account' },{- name: 'subAgent(prompt, opts?)',- description: 'Spawn a sub-agent (Claude/Codex) with optional structured output',+ name: 'experimental_subAgent(prompt, opts?)',+ description: 'Experimental sub-agent helper (Claude/Codex) with optional structured output',},{name: 'result.prompt()',@@ -351,7 +351,7 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp> = {` console.log(await f("https://gmail.googleapis.com/gmail/v1/users/me/profile"));`,`'`,'',- '# subAgent + z + result.prompt() — structured output from a sub-agent',+ '# experimental_subAgent + z + result.prompt() — structured output from a sub-agent',`composio run '`,` const [emails, issues] = await Promise.all([`,` execute("GMAIL_FETCH_EMAILS", { max_results: 5 }),`,@@ -359,7 +359,7 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp> = {` ]);`,` // result.prompt() serializes helper output for LLM consumption`,` // z is a global from zod for defining structured output schemas`,- ` const brief = await subAgent(`,+ ` const brief = await experimental_subAgent(`,` \`Summarize these emails and issues.\\n\\n\${emails.prompt()}\\n\\n\${issues.prompt()}\`,`,` { schema: z.object({ summary: z.string(), urgent: z.array(z.string()) }) }`,` );`,@@ -984,7 +984,7 @@ export function printRootHelp(): Effect.Effect<void> {` execute("GMAIL_FETCH_EMAILS", { max_results: 5 }),`,` execute("GITHUB_LIST_REPOSITORY_ISSUES", { owner: "acme", repo: "app", state: "open" }),`,` ]);`,- ` const brief = await subAgent(\`Summarize:\\n\${emails.prompt()}\\n\${issues.prompt()}\`);`,+ ` const brief = await experimental_subAgent(\`Summarize:\\n\${emails.prompt()}\\n\${issues.prompt()}\`);`,` console.log(brief);`,` '`,'',diff --git a/ts/packages/cli/src/commands/run.cmd.ts b/ts/packages/cli/src/commands/run.cmd.tsindex 43ea878fe..3dc217cd2 100644--- a/ts/packages/cli/src/commands/run.cmd.ts+++ b/ts/packages/cli/src/commands/run.cmd.ts@@ -232,9 +232,9 @@ const buildRunBaseHelpersSource = (): ReadonlyArray<string> => ['let perfDebugSeq = 0;','const proxySessionCache = new Map();','const composioBaseURL = (helperContext.baseURL || "https://backend.composio.dev").replace(/\\/$/, "");',- 'const subAgentSchema = {',+ 'const experimentalSubAgentSchema = {',' type: "function",',- ' description: "Prompt a sub-agent from the same agent family as the current main agent (Codex -> Codex, Claude -> Claude) and return its final response.",',+ ' 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.",',' parameters: {',' type: "object",',' additionalProperties: false,',@@ -320,42 +320,42 @@ const buildRunBaseHelpersSource = (): ReadonlyArray<string> => ['const formatHelperDebugEvent = (step, details = {}) => {',' switch (step) {',' case "subAgent.target":',- ' return `[subAgent] triggered with ${details.resolvedTarget}`;',+ ' return `[experimental_subAgent] triggered with ${details.resolvedTarget}`;',' case "subAgent.acp.resolve":',- ' return `[subAgent] ACP via ${details.source} (${details.target})`;',+ ' return `[experimental_subAgent] ACP via ${details.source} (${details.target})`;',' case "subAgent.acp.initialized":',- ' return `[subAgent] ACP initialized (${details.target})`;',+ ' return `[experimental_subAgent] ACP initialized (${details.target})`;',' case "subAgent.acp.session":',- ' return `[subAgent] session ready (${details.target})`;',+ ' return `[experimental_subAgent] session ready (${details.target})`;',' case "subAgent.acp.model":',' return details.applied === true',- ' ? `[subAgent] model=${details.model}`',- ' : `[subAgent] model unchanged (${details.model})`;',+ ' ? `[experimental_subAgent] model=${details.model}`',+ ' : `[experimental_subAgent] model unchanged (${details.model})`;',' case "subAgent.acp.message": {',' const text = previewDebugValue(details.text);',- ' return text ? `[subAgent] ${text}` : null;',+ ' return text ? `[experimental_subAgent] ${text}` : null;',' }',' case "subAgent.acp.thought": {',' const text = previewDebugValue(details.text);',- ' return text ? `[subAgent:thinking] ${text}` : null;',+ ' return text ? `[experimental_subAgent:thinking] ${text}` : null;',' }',' case "subAgent.acp.tool_call": {',' const where = Array.isArray(details.locations) && details.locations.length > 0 ? ` ${details.locations.slice(0, 2).join(", ")}` : "";',- ' return `[subAgent:tool] ${details.status || "pending"} ${details.title || details.kind || "tool"}${where}`;',+ ' return `[experimental_subAgent:tool] ${details.status || "pending"} ${details.title || details.kind || "tool"}${where}`;',' }',' case "subAgent.acp.tool_call_update": {',' const where = Array.isArray(details.locations) && details.locations.length > 0 ? ` ${details.locations.slice(0, 2).join(", ")}` : "";',' const preview = previewDebugValue(details.rawOutput);',- ' return `[subAgent:tool] ${details.status || "update"} ${details.title || details.toolCallId || details.kind || "tool"}${where}${preview ? ` -> ${preview}` : ""}`;',+ ' return `[experimental_subAgent:tool] ${details.status || "update"} ${details.title || details.toolCallId || details.kind || "tool"}${where}${preview ? ` -> ${preview}` : ""}`;',' }',' case "subAgent.acp.plan": {',' const entries = Array.isArray(details.entries) ? details.entries : [];',- ' if (entries.length === 0) return "[subAgent:plan] updated";',+ ' if (entries.length === 0) return "[experimental_subAgent:plan] updated";',' const summary = entries.slice(0, 3).map((entry) => `${entry.status}:${truncateDebugText(entry.content || "", 48)}`).join(" | ");',- ' return `[subAgent:plan] ${summary}`;',+ ' return `[experimental_subAgent:plan] ${summary}`;',' }',' case "subAgent.acp.fallback":',- ' return `[subAgent] ACP fallback (${details.code})`;',+ ' return `[experimental_subAgent] ACP fallback (${details.code})`;',' case "execute.prepare":',' return `[execute] ${details.slug}`;',' case "search.prepare":',@@ -471,14 +471,14 @@ const buildRunBaseHelpersSource = (): ReadonlyArray<string> => [' if (detected === "codex" || detected === "claude") return detected;',' if (typeof Bun.which === "function" && Bun.which("codex")) return "codex";',' if (typeof Bun.which === "function" && Bun.which("claude")) return "claude";',- ' throw new Error("subAgent() could not determine an agent CLI. Current master is user; install codex or claude, or pass { target: \\"codex\\" | \\"claude\\" }.");',+ ' throw new Error("experimental_subAgent() could not determine an agent CLI. Current master is user; install codex or claude, or pass { target: \\"codex\\" | \\"claude\\" }.");','};','const normalizeInvokeAgentOptions = (options = {}) => {',' if (options == null || typeof options !== "object" || Array.isArray(options)) {',- ' throw new Error("subAgent() options must be an object when provided.");',+ ' throw new Error("experimental_subAgent() options must be an object when provided.");',' }',' if (options.schema !== undefined && options.jsonSchema !== undefined) {',- ' throw new Error("subAgent() accepts either options.schema or options.jsonSchema, not both.");',+ ' throw new Error("experimental_subAgent() accepts either options.schema or options.jsonSchema, not both.");',' }',' const inputSchema = options.schema ?? options.jsonSchema;',' let structuredSchema;',@@ -486,14 +486,14 @@ const buildRunBaseHelpersSource = (): ReadonlyArray<string> => [' if (inputSchema !== undefined) {',' if (inputSchema && typeof inputSchema.safeParse === "function" && inputSchema._def) {',' if (typeof z.toJSONSchema !== "function") {',- ' throw new Error("subAgent() requires Zod 4 with z.toJSONSchema() when using options.schema.");',+ ' throw new Error("experimental_subAgent() requires Zod 4 with z.toJSONSchema() when using options.schema.");',' }',' zodSchema = inputSchema;',' structuredSchema = z.toJSONSchema(inputSchema);',' } else if (typeof inputSchema === "object" && inputSchema !== null && !Array.isArray(inputSchema)) {',' structuredSchema = inputSchema;',' } else {',- ' throw new Error("subAgent() schema must be a Zod schema or JSON Schema object.");',+ ' throw new Error("experimental_subAgent() schema must be a Zod schema or JSON Schema object.");',' }',' }',' return { ...options, structuredSchema, zodSchema };',@@ -694,9 +694,9 @@ const buildRunBaseHelpersSource = (): ReadonlyArray<string> => [];const buildRunInvokeAgentHelpersSource = (): ReadonlyArray<string> => [- 'const subAgentImpl = async (prompt, options = {}) => {',+ 'const experimentalSubAgentImpl = async (prompt, options = {}) => {',' if (typeof prompt !== "string" || prompt.trim().length === 0) {',- ' throw new Error("subAgent() requires a non-empty prompt string.");',+ ' throw new Error("experimental_subAgent() requires a non-empty prompt string.");',' }',' const logFilePath = typeof helperContext.runLogFilePath === "string" && helperContext.runLogFilePath.length > 0 ? helperContext.runLogFilePath : undefined;',' const normalizedOptions = normalizeInvokeAgentOptions(options);',@@ -732,10 +732,10 @@ const buildRunInvokeAgentHelpersSource = (): ReadonlyArray<string> => [' return logFilePath ? { ...response, logFilePath } : response;',' }','};',- 'globalThis.subAgent = subAgentImpl;',- 'Object.defineProperty(globalThis.subAgent, "schema", { value: subAgentSchema });',- 'globalThis.invokeAgent = subAgentImpl;',- 'Object.defineProperty(globalThis.invokeAgent, "schema", { value: subAgentSchema });',+ 'globalThis.experimental_subAgent = experimentalSubAgentImpl;',+ 'Object.defineProperty(globalThis.experimental_subAgent, "schema", { value: experimentalSubAgentSchema });',+ 'globalThis.invokeAgent = experimentalSubAgentImpl;',+ 'Object.defineProperty(globalThis.invokeAgent, "schema", { value: experimentalSubAgentSchema });','',];@@ -995,7 +995,7 @@ export const runCmd = Command.make('run', {` execute("GMAIL_FETCH_EMAILS", { max_results: 5 }),`,` execute("GITHUB_LIST_REPOSITORY_ISSUES", { owner: "composiohq", repo: "composio", state: "open" }),`,` ]);`,- ` const brief = await subAgent(`,+ ` const brief = await experimental_subAgent(`,` \`Create a morning brief from these emails and issues.\\n\\n\${emails.prompt()}\\n\\n\${issues.prompt()}\`,`,` {`,` schema: z.object({`,@@ -1012,9 +1012,9 @@ export const runCmd = Command.make('run', {'Injected helpers (behave like their CLI counterparts):',' execute(slug, data?) Same as `composio execute` — returns parsed JSON',' search(query, options?) Same as `composio search` — returns matching tools',- ' subAgent(prompt, options?) Spawn a powerful sub-agent from the same agent family as your current main agent',+ ' experimental_subAgent(prompt, options?) Experimental helper to spawn a powerful sub-agent from the same agent family as your current main agent',' (Codex -> Codex, Claude -> Claude) with optional Zod structured output',- ' result.prompt() Prompt-safe serialization of a helper result, ideal for subAgent(...)',+ ' result.prompt() Prompt-safe serialization of a helper result, ideal for experimental_subAgent(...)',' const f = await proxy(toolkit) Same as `composio proxy` — returns a fetch function',' Example: const f = await proxy("gmail")',' const me = await f("https://gmail.googleapis.com/gmail/v1/users/me/profile")',@@ -1025,7 +1025,7 @@ export const runCmd = Command.make('run', {'Flags:',' --debug Log helper steps while the script runs',' --dry-run Preview execute() calls without running them',- ' --logs-off Hide the always-on subAgent streaming logs',+ ' --logs-off Hide the always-on experimental_subAgent streaming logs',' --skip-connection-check Skip the connected-account check',' --skip-tool-params-check Skip input validation against cached schema',' --skip-checks Skip both checks above',diff --git a/ts/packages/cli/src/services/project-environment-detector.ts b/ts/packages/cli/src/services/project-environment-detector.tsindex 4e928636c..d98e359df 100644--- a/ts/packages/cli/src/services/project-environment-detector.ts+++ b/ts/packages/cli/src/services/project-environment-detector.ts@@ -431,7 +431,10 @@ const detectLanguage = (fs: FileSystem.FileSystem, cwd: string) =>if (evidence.strongPy)return { language: 'python' as const, rootDir: dir, evidence } as const;- const weakCandidate = pickBestWeak(evidence, depth);+ // Only allow weak detection at the requested cwd. Walking weak signals up+ // arbitrary ancestor directories causes false positives in temp dirs and+ // other shared parent paths outside the actual project.+ const weakCandidate = depth === 0 ? pickBestWeak(evidence, depth) : null;if (weakCandidate && (!bestWeak || weakCandidate.score > bestWeak.score))bestWeak = weakCandidate;}diff --git a/ts/packages/cli/src/services/run-subagent-legacy.ts b/ts/packages/cli/src/services/run-subagent-legacy.tsindex dc9e179bf..a0221ad06 100644--- a/ts/packages/cli/src/services/run-subagent-legacy.ts+++ b/ts/packages/cli/src/services/run-subagent-legacy.ts@@ -4,7 +4,6 @@ import * as path from 'node:path';import { spawn } from 'node:child_process';import type { MasterKind } from 'src/services/master-detector';import {- finalizeInvokeAgentText,parseJson,toInvokeAgentResponse,type HelperDebugLog,@@ -85,7 +84,7 @@ const invokeClaudeLegacy = async (const result = await runExternalCommandText(args, helperDebugLog);const parsed = parseJson(result.stdout.trim());if (!parsed || typeof parsed !== 'object') {- throw new Error('claude returned non-JSON output in subAgent().');+ throw new Error('claude returned non-JSON output in experimental_subAgent().');}const payload =diff --git a/ts/packages/cli/src/services/run-subagent-output-mcp.ts b/ts/packages/cli/src/services/run-subagent-output-mcp.tsindex fba34162f..929019cc0 100644--- a/ts/packages/cli/src/services/run-subagent-output-mcp.ts+++ b/ts/packages/cli/src/services/run-subagent-output-mcp.ts@@ -79,7 +79,7 @@ const main = async (): Promise<void> => {{title: 'Submit structured output',description:- 'Submit the final structured subAgent output. Call this exactly once when the task is complete.',+ 'Submit the final structured experimental_subAgent output. Call this exactly once when the task is complete.',inputSchema: toolInputSchema,},async (payload: unknown) => {diff --git a/ts/packages/cli/src/services/run-subagent-shared.ts b/ts/packages/cli/src/services/run-subagent-shared.tsindex b1622af92..0c4aeacb4 100644--- a/ts/packages/cli/src/services/run-subagent-shared.ts+++ b/ts/packages/cli/src/services/run-subagent-shared.ts@@ -223,7 +223,7 @@ export const validateStructuredOutput = (const validation = options.zodSchema.safeParse(parsed);if (!validation.success) {throw new Error(- `subAgent() structured output failed schema validation: ${summarizeValidationError(validation.error)}`+ `experimental_subAgent() structured output failed schema validation: ${summarizeValidationError(validation.error)}`);}@@ -373,10 +373,9 @@ export const finalizeInvokeAgentText = (};}- let parsed: unknown;- parsed = tryParseStructuredJson(trimmed);+ const parsed = tryParseStructuredJson(trimmed);if (parsed === undefined) {- throw new Error('subAgent() expected valid JSON output for structured response.');+ throw new Error('experimental_subAgent() expected valid JSON output for structured response.');}return {diff --git a/ts/packages/cli/test/src/commands/run.cmd.test.ts b/ts/packages/cli/test/src/commands/run.cmd.test.tsindex 4f89128c5..a4a593aea 100644--- a/ts/packages/cli/test/src/commands/run.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/run.cmd.test.ts@@ -170,7 +170,7 @@ describe('CLI: composio run', () => {layer(TestLive())(it => {it.scoped(- '[Given] run help [Then] it documents injected execute, search, proxy, subAgent, and z helpers',+ '[Given] run help [Then] it documents injected execute, search, proxy, experimental_subAgent, and z helpers',() =>Effect.gen(function* () {yield* cli(['run', '--help']);@@ -183,7 +183,7 @@ describe('CLI: composio run', () => {expect(output).toContain('--skip-tool-params-check');expect(output).toContain('--skip-checks');expect(output).toContain('--logs-off');- expect(output).toContain('subAgent');+ expect(output).toContain('experimental_subAgent');expect(output).toContain('schema: z.object');expect(output).toContain('INJECTED HELPERS');expect(output).toContain('Global from zod');@@ -234,7 +234,9 @@ describe('buildRunHelpersSource', () => {expect(source).toContain('storedInFilePath: outputFilePath !== null,');expect(source).toContain('outputFilePath,');expect(source).toContain('const formatHelperDebugEvent = (step, details = {}) => {');- expect(source).toContain('return `[subAgent] triggered with ${details.resolvedTarget}`;');+ expect(source).toContain(+ 'return `[experimental_subAgent] triggered with ${details.resolvedTarget}`;'+ );expect(source).toContain('const logCliResultPreview = (requestId, command, result) => {');expect(source).toContain('helperDebugLog("cli.result", {');expect(source).toContain('helperDebugLog("cli.result.stored_in_file"');@@ -251,11 +253,11 @@ describe('buildRunHelpersSource', () => {'if (result && typeof result === "object" && result.successful === false) {');expect(source).toContain('Object.assign(error, { result, slug });');- expect(source).toContain('globalThis.subAgent = subAgentImpl;');+ expect(source).toContain('globalThis.experimental_subAgent = experimentalSubAgentImpl;');expect(source).toContain(- 'Object.defineProperty(globalThis.subAgent, "schema", { value: subAgentSchema });'+ 'Object.defineProperty(globalThis.experimental_subAgent, "schema", { value: experimentalSubAgentSchema });');- expect(source).toContain('globalThis.invokeAgent = subAgentImpl;');+ expect(source).toContain('globalThis.invokeAgent = experimentalSubAgentImpl;');expect(source).toContain('const logFilePath = typeof helperContext.runLogFilePath === "string"');@@ -267,12 +269,12 @@ describe('buildRunHelpersSource', () => {expect(source).toContain('const response = await invokeLegacySubAgent({');expect(source).toContain('const detectInvokeAgentMaster = () => {');expect(source).toContain(- 'throw new Error("subAgent() accepts either options.schema or options.jsonSchema, not both.");'+ 'throw new Error("experimental_subAgent() accepts either options.schema or options.jsonSchema, not both.");');expect(source).toContain('const inputSchema = options.schema ?? options.jsonSchema;');expect(source).toContain('if (typeof z.toJSONSchema !== "function") {');expect(source).toContain(- 'subAgent() requires Zod 4 with z.toJSONSchema() when using options.schema.'+ 'experimental_subAgent() requires Zod 4 with z.toJSONSchema() when using options.schema.');expect(source).toContain('let zodSchema;');expect(source).toContain('zodSchema = inputSchema;');@@ -366,7 +368,7 @@ describe('run-subagent-shared', () => {finalizeInvokeAgentText('not-json', {structuredSchema: { type: 'object' },})- ).toThrow('subAgent() expected valid JSON output for structured response.');+ ).toThrow('experimental_subAgent() expected valid JSON output for structured response.');});it('[Given] prose followed by JSON in structured mode [Then] it recovers the final JSON payload', () => {