From 236beefb708a6cd91b673978ddf4ebf045a9844c Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Sat, 23 May 2026 16:59:20 +0900 Subject: feat: key fallback using agent models[] hierarchy, background tool modes, copy truncation - Agent rate-limit fallback now iterates through agent's configured models[] in strict order - Frontend sends agentModels with each /chat request; backend uses buildFallbackSequence() - Emits notice event on fallback so chat shows which key failed and what's being tried next - Child agents inherit parent's agentModels for fallback - Added statusCode propagation from AI SDK errors for programmatic 429 detection - Copy button truncates all tool results at 300 chars (was 200 for 4 specific tools) - run_shell, summon, youtube_transcribe: background mode support - summon: blocking mode by default with getResult callback --- packages/core/src/tools/run-shell.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'packages/core/src/tools/run-shell.ts') diff --git a/packages/core/src/tools/run-shell.ts b/packages/core/src/tools/run-shell.ts index 6671c31..ec2db9c 100644 --- a/packages/core/src/tools/run-shell.ts +++ b/packages/core/src/tools/run-shell.ts @@ -54,6 +54,12 @@ export function createRunShellTool( parameters: z.object({ command: z.string().describe("The shell command to execute"), timeout: z.number().optional().describe("Timeout in milliseconds (default 2 minutes)"), + background: z + .boolean() + .optional() + .describe( + "If true, the command starts in the background and a job_id is returned immediately. Use the retrieve tool with the job_id to get the result later.", + ), }), execute: async ( args: Record, @@ -61,6 +67,7 @@ export function createRunShellTool( ): Promise => { const command = args.command as string; const timeout = (args.timeout as number | undefined) ?? DEFAULT_TIMEOUT; + const background = (args.background as boolean | undefined) ?? false; const [shell, shellArgs] = getShell(); const child = spawn(shell, [...shellArgs, command], { @@ -99,6 +106,23 @@ export function createRunShellTool( }); }); + // If background mode requested, register immediately and return job ID + if (background && shellStore) { + const jobId = shellStore.register({ + command, + stdout, + stderr, + completion: completionPromise, + }); + return [ + `Command started in background.`, + `job_id: ${jobId}`, + `command: ${command}`, + ``, + `Use the retrieve tool with this job_id to get the result when ready.`, + ].join("\n"); + } + const queueCallbacks = context?.queueCallbacks; if (queueCallbacks && shellStore) { -- cgit v1.2.3