fix: add auto-notification guidance to background task return value (#942)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-02-12 17:21:18 -08:00
committed by GitHub
parent eb0453d400
commit 5a696e6116

View File

@@ -426,7 +426,14 @@ export async function task(args: TaskArgs): Promise<string> {
await waitForBackgroundSubagentLink(subagentId, null, signal);
return `Task running in background with ID: ${taskId}\nOutput file: ${outputFile}`;
// Extract Letta agent ID from subagent state (available after link resolves)
const linkedAgent = getSubagentSnapshot().agents.find(
(a) => a.id === subagentId,
);
const agentId = linkedAgent?.agentURL?.split("/agents/")[1] ?? null;
const agentIdLine = agentId ? `\nAgent ID: ${agentId}` : "";
return `Task running in background with task ID: ${taskId}${agentIdLine}\nOutput file: ${outputFile}\n\nYou will be notified automatically when this task completes — a <task-notification> message will be delivered with the result. No need to poll, sleep-wait, or check the output file. Just continue with your current work.`;
}
// Register subagent with state store for UI display (foreground path)