feat: capability-based routing (v8)
Policy carries an operator-declared model_capabilities directory and per-tier requires (tool_calling/reasoning/vision booleans, min_context_tokens). decide_routing checks the policy tier model in active mode: capable applies, incapable falls back to a capable worker default, and if both fail or are unknown it returns capability_blocked, which the worker turns into a failed task (v3 tools-gate shape, runner never called). Shadow mode only annotates the reason, never blocks. Explicit task and worker CLI models bypass the check by design. Invalid requires drops only that tier (fail-closed, like invalid tier mode). Dry-run reports per-tier capability status and blocks on active tiers that fail or cannot be verified.
This commit is contained in:
1 parent
362dffba4f
commit
cd33a929ca
4 files changed
+616
-11
No files matched your search
@@ -6036,6 +6036,36 @@ class Worker:
|
||||
decision = decide_routing(
|
||||
task, self.model, policy=self.routing_policy,
|
||||
worker_model_explicit=self.model_explicit)
|
||||
# 能力门(v8):策略档模型与 worker 默认都满足不了
|
||||
# 档需求时,绝不静默派给一个不具备或无法验证的模型,
|
||||
# 按 v3 必需工具门同款 fail-fast:任务直接 failed、
|
||||
# 审计点名原因、清占位、不调 runner。显式任务模型
|
||||
# 与 worker CLI 模型在 decide_routing 内已优先,
|
||||
# 永远不会走到这里被能力门拦。
|
||||
if decision.source == "capability_blocked":
|
||||
_cap_error = decision.reason
|
||||
self._set_status(task_id, "failed")
|
||||
self._write_execution_result(
|
||||
task_id, error_text=_cap_error,
|
||||
actual_model=self.model,
|
||||
started_at=started_at, finished_at=time.time(),
|
||||
only_if_status="failed")
|
||||
self._audit(task["project_id"],
|
||||
"worker_capability_gate_rejected",
|
||||
"%s: %s" % (task_id, _cap_error))
|
||||
log_event(self.logger,
|
||||
"worker_capability_gate_rejected",
|
||||
task_id=task_id, project_id=task["project_id"],
|
||||
status="failed")
|
||||
self._running_clear(task_id)
|
||||
return {"dispatched": True, "task_id": task_id,
|
||||
"host_name": self.executor._host_name(task)
|
||||
if hasattr(self.executor, "_host_name")
|
||||
else task_id,
|
||||
"status": "failed",
|
||||
"executor": self._executor_name(),
|
||||
"stdout": "", "error": _cap_error, "events": [],
|
||||
"cost_record_id": None}
|
||||
# 只在策略真正介入时记事件与审计:worker_default /
|
||||
# worker_explicit 就是旧行为,记一条 model_routing 会
|
||||
# 打破现有调用方对 events 的假设(例如 fallback 单测
|
||||
|
||||
Reference in new issue
Block a user