feat(coordinator): 添加团队节点默认最大工具迭代次数配置

添加 DEFAULT_TEAM_NODE_MAX_TOOL_ITERATIONS 配置项以控制团队节点的最大工具迭代次数,
并修改 LocalAgentRunner 中的逻辑来使用此默认值当 envelope 中未指定时。

fix(runtime): 修复团队节点运行成功判断逻辑

更新运行成功判断条件,将 finish_reason 为 "max_tool_iterations_finalized" 的情况
视为运行失败,并添加对原始工具调用输出的检测,避免将其误判为成功完成。

feat(mcp): 添加团队工作流MCP工具类别支持

增加新的本地MCP工具类别 "team_workflow" 及其对应的工具创建功能,
为团队工作流提供本地工具支持。

refactor(engine): 调整AgentLoop最大工具迭代次数设置

将 AgentProfile 中的默认 max_tool_iterations 从 30 增加到 100,
同时移除 TaskExecutionPlanner 构造函数中的重复参数传递。

perf(mcp): 优化MCP连接管理避免重复连接

添加 mcp_connected 标志来跟踪MCP连接状态,确保 connect_all 只执行一次,
提高性能并避免不必要的重复连接。

refactor(skills): 移除技能团队模板相关功能

移除与技能团队模板相关的代码,包括解析、存储和处理逻辑,
简化技能记录结构和加载流程。

feat(process): 增强会话过程投影器功能

添加技能激活快照事件处理,改进团队运行完成消息显示,
并增强技能激活事件的时间戳记录功能。

refactor(tasks): 简化任务尝试编排器团队执行逻辑

移除团队执行相关代码,将所有任务统一按单步执行处理,
简化任务编排器的复杂度并提升执行效率。

fix(evidence): 修复节点证据评估中需求验证逻辑

更新节点证据评估逻辑,跳过自然语言证据需求的确定性验证,
只执行机器可读的需求验证,避免因自然语言需求导致的节点失败。
This commit is contained in:
2026-06-26 16:36:29 +08:00
parent 53b13e8eac
commit 520a21a027
360 changed files with 13271 additions and 1848 deletions

View File

@ -17,6 +17,7 @@ class SessionProcessProjector:
runs: dict[str, dict[str, Any]] = {}
events: list[dict[str, Any]] = []
artifacts: list[dict[str, Any]] = []
projected_skill_activation_run_ids: set[str] = set()
def add_event(
*,
@ -186,6 +187,38 @@ class SessionProcessProjector:
},
)
elif record.event_type == "skill_activation_snapshotted":
run_id = record.run_id or root_run_id
parent_run_id = root_run_id if run_id != root_run_id else None
receipts = [
item
for item in payload.get("receipts") or []
if isinstance(item, dict)
]
selected_skill_names = _receipt_skill_names(receipts)
if selected_skill_names:
projected_skill_activation_run_ids.add(str(run_id))
add_event(
event_id=_event_id(record, "skill-activation"),
run_id=str(run_id),
parent_run_id=parent_run_id,
kind="skill_selected",
actor_type="system",
actor_id="skill-selector",
actor_name="Skill Selector",
text=f"Selected skill guidance: {', '.join(selected_skill_names)}.",
created_at=_receipt_started_at(receipts) or created_at,
status="done",
metadata={
"task_id": task_id,
"attempt_index": attempt_index,
"timeline_type": "skill",
"skill_names": selected_skill_names,
"activation_reasons": _receipt_reasons(receipts),
"receipts": receipts,
},
)
elif record.event_type in {"task_team_run_completed", "task_team_run_failed"}:
team_success = bool(payload.get("team_success"))
root["status"] = "running"
@ -203,7 +236,7 @@ class SessionProcessProjector:
actor_type="system",
actor_id="team",
actor_name="Task Team",
text=payload.get("error") or ("Team completed" if team_success else "Team completed with failed nodes"),
text="Team completed" if team_success else "Team 执行未完成 / 子节点失败",
created_at=created_at,
status="done" if team_success else "error",
metadata={**dict(payload), "timeline_type": "agent_team", "team_run_ids": team_run_ids},
@ -316,7 +349,10 @@ class SessionProcessProjector:
"skill_names": activated_skill_names,
},
}
if activated_skill_names:
if activated_skill_names and main_run_id not in projected_skill_activation_run_ids:
skill_created_at = _activated_skill_started_at(run_record) or (
run_record.started_at if run_record is not None else None
) or created_at
add_event(
event_id=_event_id(record, "synthesis-skills"),
run_id=main_run_id,
@ -326,7 +362,7 @@ class SessionProcessProjector:
actor_id="skill-selector",
actor_name="Skill Selector",
text=f"Selected skill guidance: {', '.join(activated_skill_names)}.",
created_at=created_at,
created_at=skill_created_at,
status="done",
metadata={
"task_id": task_id,
@ -439,6 +475,48 @@ def _activated_skill_reasons(run_record: Any | None) -> list[str]:
return reasons
def _activated_skill_started_at(run_record: Any | None) -> str | None:
if run_record is None:
return None
timestamps = [
str(getattr(receipt, "activated_at", "") or "").strip()
for receipt in getattr(run_record, "activated_skills", []) or []
]
timestamps = [value for value in timestamps if value]
if not timestamps:
return None
return sorted(timestamps)[0]
def _receipt_skill_names(receipts: list[dict[str, Any]]) -> list[str]:
names = []
for receipt in receipts:
skill_name = str(receipt.get("skill_name") or "").strip()
if skill_name:
names.append(skill_name)
return list(dict.fromkeys(names))
def _receipt_reasons(receipts: list[dict[str, Any]]) -> list[str]:
reasons = []
for receipt in receipts:
reason = str(receipt.get("activation_reason") or "").strip()
if reason:
reasons.append(reason)
return reasons
def _receipt_started_at(receipts: list[dict[str, Any]]) -> str | None:
timestamps = [
str(receipt.get("activated_at") or "").strip()
for receipt in receipts
]
timestamps = [value for value in timestamps if value]
if not timestamps:
return None
return sorted(timestamps)[0]
def _tool_call_name(tool_call: dict[str, Any]) -> str:
function_payload = tool_call.get("function")
if isinstance(function_payload, dict):