|
|
@@ -739,15 +739,7 @@ public class AgentChatServiceImpl extends ServiceImpl<AgentChatSessionMapper, Ag
|
|
|
// 子代理完整报告只作为父 Agent 的输入:tool_events 只存 alias/status/duration/summary,
|
|
|
// 输入侧也去掉完整任务简报,避免把子代理全文写进 agent_message。
|
|
|
if ("agent_spawn".equals(e.getToolCallName())) {
|
|
|
- // agent_spawn 的入参没有 agent_id(工具集由 tools 指定),别名优先从结果头取,
|
|
|
- // 后台受理结果没有头时用固定别名兜底
|
|
|
- String alias = jsonStringField(toolInputs.get(e.getToolCallId()), "agent_id");
|
|
|
- if (alias == null) {
|
|
|
- alias = firstLineValue(text, "agent_id");
|
|
|
- }
|
|
|
- if (alias == null) {
|
|
|
- alias = "general-purpose";
|
|
|
- }
|
|
|
+ String alias = resolveSpawnAlias(toolInputs.get(e.getToolCallId()), text);
|
|
|
Long startedAt = process.toolStartedAt.remove(e.getToolCallId());
|
|
|
long durationMs = startedAt == null ? 0 : System.currentTimeMillis() - startedAt;
|
|
|
String projection = projectAgentSpawnResult(alias, text, durationMs);
|
|
|
@@ -1300,7 +1292,8 @@ public class AgentChatServiceImpl extends ServiceImpl<AgentChatSessionMapper, Ag
|
|
|
String parsed = firstLineValue(text, "status");
|
|
|
status = parsed == null || parsed.isBlank() ? "ok" : parsed;
|
|
|
summary = switch (status) {
|
|
|
- case "ok" -> reportSummary(text);
|
|
|
+ case "ok" -> text.contains("<persisted-output>")
|
|
|
+ ? "报告较长,已落盘(完整路径见工具输出)" : reportSummary(text);
|
|
|
case "accepted" -> "已转入后台运行";
|
|
|
case "timeout_promoted" -> "同步等待超时,已转后台继续运行";
|
|
|
default -> status;
|
|
|
@@ -1337,7 +1330,10 @@ public class AgentChatServiceImpl extends ServiceImpl<AgentChatSessionMapper, Ag
|
|
|
|| trimmed.startsWith("task_id:")
|
|
|
|| trimmed.startsWith("agent_key:")
|
|
|
|| trimmed.startsWith("agent_id:")
|
|
|
- || trimmed.startsWith("session_id:")) {
|
|
|
+ || trimmed.startsWith("session_id:")
|
|
|
+ || trimmed.startsWith("#")
|
|
|
+ || trimmed.startsWith(">")
|
|
|
+ || trimmed.startsWith("---")) {
|
|
|
continue;
|
|
|
}
|
|
|
return truncateText(trimmed, 180);
|
|
|
@@ -1404,6 +1400,23 @@ public class AgentChatServiceImpl extends ServiceImpl<AgentChatSessionMapper, Ag
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * agent_spawn 的展示别名:入参 {@code subagent_type}(本项目档案选择)→ 旧入参 {@code agent_id}
|
|
|
+ * → 结果头的 {@code agent_id} → 默认档案。
|
|
|
+ *
|
|
|
+ * <p>后台受理结果没有 agent_id 头,若不从入参取,任务卡片会错误显示 general-purpose。
|
|
|
+ */
|
|
|
+ static String resolveSpawnAlias(StringBuilder inputJson, String resultText) {
|
|
|
+ String alias = jsonStringField(inputJson, "subagent_type");
|
|
|
+ if (alias == null || alias.isBlank()) {
|
|
|
+ alias = jsonStringField(inputJson, "agent_id");
|
|
|
+ }
|
|
|
+ if (alias == null || alias.isBlank()) {
|
|
|
+ alias = firstLineValue(resultText, "agent_id");
|
|
|
+ }
|
|
|
+ return alias == null || alias.isBlank() ? "general-purpose" : alias;
|
|
|
+ }
|
|
|
+
|
|
|
private static String truncateText(String text, int max) {
|
|
|
if (text == null) {
|
|
|
return "";
|