fix(agent): failure reason leads with model's diagnosis, not the task prompt
之前聚合用 "<任务描述前80字>: <error>",失败 reason 被整段 prompt 污染, 真正的"看到什么/缺什么"被挤到后面。改为以模型 summary 为主、附上 distinct error, reason 直接就是诊断本身(例:"No source files found...; only README/jsonl present. (Required files like src/database/redis/main.js are missing.)")。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
62d6fdf78c
commit
26a40c7770
+15
-8
@@ -126,15 +126,22 @@ class TaskExecutor:
|
||||
"usage": self._usage_payload(time.time() - started_at),
|
||||
}
|
||||
if not success:
|
||||
# Surface the real per-subtask failure detail as a top-level `error` so the
|
||||
# orchestrator records WHY (agent/main.py falls back to a generic "Task failed"
|
||||
# when this key is absent — see incident 2026-06-15 swarm-69e470561bd7-seed).
|
||||
# Surface the model's OWN failure explanation (what it saw / what was missing) as a
|
||||
# top-level `error`, so the orchestrator/Manager records WHY instead of a generic
|
||||
# "Task failed" (agent/main.py uses this as the failure reason). Lead with the model's
|
||||
# summary/error — NOT the task prompt — so the reason reads as the diagnosis, not the
|
||||
# ask. summary is usually the fuller "saw X, missing Y" narrative; append a distinct
|
||||
# error for the concise cause.
|
||||
failed = [r for r in results if r.get("status") not in ("completed", "handed_off")]
|
||||
detail = "; ".join(
|
||||
f"{((r.get('subtask') or {}).get('description') or 'subtask')[:80]}: "
|
||||
f"{r.get('error') or r.get('summary') or 'no detail reported'}"
|
||||
for r in failed
|
||||
) or "subtask(s) failed without detail"
|
||||
explanations = []
|
||||
for r in failed:
|
||||
summary = str(r.get("summary") or "").strip()
|
||||
error = str(r.get("error") or "").strip()
|
||||
text = summary or error or "subtask failed without detail"
|
||||
if summary and error and error not in summary:
|
||||
text = f"{summary} ({error})"
|
||||
explanations.append(text)
|
||||
detail = "; ".join(explanations) or "subtask(s) failed without detail"
|
||||
payload["error"] = detail
|
||||
logger.error(f"Task {task_id} failed: {detail}")
|
||||
return payload
|
||||
|
||||
Reference in New Issue
Block a user