From e5abdf06727ad0dfa7140541af59bbc9009318ba Mon Sep 17 00:00:00 2001 From: viettranx Date: Tue, 3 Mar 2026 18:05:42 +0700 Subject: [PATCH] fix(delegation): notify user on failure before retry + pending tasks hint Two improvements to delegation UX: 1. When a delegation fails, the announce now instructs the coordinator to send a brief friendly message to the user before retrying, so users aren't left waiting in silence for minutes. 2. When spawn is called with a wrong team_task_id (LLM hallucinated UUID), the error now includes a list of pending tasks so the model can self-correct. Also refactored prepareDelegation to resolve team once instead of 3 separate GetTeamForAgent calls. Co-Authored-By: Claude Opus 4.6 --- internal/tools/delegate_events.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/tools/delegate_events.go b/internal/tools/delegate_events.go index ac4f8f4a..00a76d95 100644 --- a/internal/tools/delegate_events.go +++ b/internal/tools/delegate_events.go @@ -34,7 +34,9 @@ func formatDelegateAnnounce(task *DelegationTask, artifacts *DelegateArtifacts, if err != nil && len(artifacts.Results) == 0 { return fmt.Sprintf( "[System Message] All delegations finished. The last delegation to agent %q failed.\n\nError: %s\n\nStats: runtime %s\n\n"+ - "Handle the failed task yourself or try a different agent.", + "IMPORTANT: Before retrying or handling the task yourself, send a brief, friendly message to the user "+ + "letting them know there was a small hiccup and you're working on it. Keep it short and natural (1-2 sentences). "+ + "Then retry the delegation or handle it yourself.", task.TargetAgentKey, err.Error(), elapsed.Round(time.Millisecond)) }