auto-sync: 2026-05-20 00:04:50
This commit is contained in:
@@ -117,8 +117,30 @@ class Dispatcher:
|
||||
|
||||
Returns:
|
||||
{"level": str, "agent_id": str, "session_id": Optional[str],
|
||||
"status": "dispatched"|"skipped"|"error", "reason": str}
|
||||
"status": "dispatched"|"skipped"|"error"|"blocked", "reason": str}
|
||||
"""
|
||||
# 安全红线检查(调度前拦截)
|
||||
if self.guardrails:
|
||||
violations = self.guardrails.check_task(task)
|
||||
critical = [v for v in violations if v.action in ("block_and_notify", "terminate_and_escalate")]
|
||||
if critical:
|
||||
v = critical[0]
|
||||
logger.warning("Task '%s' blocked by guardrail: %s - %s",
|
||||
task.title, v.rule_id, v.message)
|
||||
# 写入黑板事件
|
||||
_routing_db = Path(project_config["db_path"]) if project_config and "db_path" in project_config else self.db_path
|
||||
if _routing_db:
|
||||
self._record_routing(task, {"level": DispatchLevel.BLOCKED, "agent_id": "none",
|
||||
"reason": v.message}, "blocked", v.message, _routing_db)
|
||||
return {
|
||||
"level": "blocked",
|
||||
"agent_id": "none",
|
||||
"session_id": None,
|
||||
"status": "blocked",
|
||||
"reason": v.message,
|
||||
"violations": [v.rule_id for v in violations],
|
||||
}
|
||||
|
||||
if self._legacy_mode:
|
||||
return await self._legacy_dispatch(task, action_type, project_config)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user