fix: improve subagent UI display and interruption handling (#330)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2025-12-21 00:09:12 -08:00
committed by GitHub
parent 90d84482ef
commit 0852ce26fe
14 changed files with 161 additions and 29 deletions

View File

@@ -1,6 +1,7 @@
import type { ExecOptions } from "node:child_process";
import { exec, spawn } from "node:child_process";
import { promisify } from "node:util";
import { INTERRUPTED_BY_USER } from "../../constants";
import { backgroundProcesses, getNextBashId } from "./process_manager.js";
import { getShellEnv } from "./shellEnv.js";
import { LIMITS, truncateByChars } from "./truncation.js";
@@ -156,7 +157,7 @@ export async function bash(args: BashArgs): Promise<BashResult> {
let errorMessage = "";
if (isAbort) {
errorMessage = "User interrupted tool execution";
errorMessage = INTERRUPTED_BY_USER;
} else {
if (err.killed && err.signal === "SIGTERM")
errorMessage = `Command timed out after ${effectiveTimeout}ms\n`;

View File

@@ -20,6 +20,7 @@ interface TaskArgs {
description: string;
model?: string;
toolCallId?: string; // Injected by executeTool for linking subagent to parent tool call
signal?: AbortSignal; // Injected by executeTool for interruption handling
}
/**
@@ -33,7 +34,8 @@ export async function task(args: TaskArgs): Promise<string> {
"Task",
);
const { subagent_type, prompt, description, model, toolCallId } = args;
const { subagent_type, prompt, description, model, toolCallId, signal } =
args;
// Get all available subagent configs (built-in + custom)
const allConfigs = await getAllSubagentConfigs();
@@ -54,12 +56,14 @@ export async function task(args: TaskArgs): Promise<string> {
prompt,
model,
subagentId,
signal,
);
// Mark subagent as completed in state store
completeSubagent(subagentId, {
success: result.success,
error: result.error,
totalTokens: result.totalTokens,
});
if (!result.success) {