feat: 子任务默认模型/强度(child_model/child_effort)

主任务可显式声明派生默认,或在 prompt 里写“子任务用 gpt-6-luna max”
由服务端解析填入;marker task-create 与协调员分工未显式写模型/强度时
按 块/分工 > 派生默认 > 父任务模型/强度 继承,fork 复制派生默认,
continue 可改派生默认;console 新建/继续表单与任务详情同步展示。
This commit is contained in:
host committed 2026-10-29 05:27:22 +08:00
1 parent f99e667222
commit 14757f15c4
7 files changed
+588 -25

No files matched your search

+46 -12
View File
@@ -347,6 +347,10 @@ def _task_from_row(row):
# 任务级选项:老行缺列时 None = 跟随配置(见 server 侧)。
"model": _col("model"),
"effort": _col("effort"),
# 派生默认:老行缺列时 None = 没有单独声明,派生时
# 先取它、再取本任务的 model / effort。
"child_model": _col("child_model"),
"child_effort": _col("child_effort"),
"approval": _col("approval"),
"plan": _col("plan"),
"forked_from": _col("forked_from"),
@@ -832,6 +836,8 @@ class Worker:
"worktree_host": "TEXT",
"model": "TEXT",
"effort": "TEXT",
"child_model": "TEXT",
"child_effort": "TEXT",
"approval": "TEXT",
"plan": "INTEGER",
"forked_from": "TEXT",
@@ -2610,33 +2616,54 @@ class Worker:
rejected += 1
continue
child_id = _marker_new_id()
# 派生模型/强度优先级:块里显式写 >
# 父任务的派生默认 child_model /
# child_effort > 父任务自身的
# model / effort > NULL(认领时走
# worker 默认)。子任务行上同时记下
# 父任务的派生默认,隔代派生不丢。
child_model = (create["model"]
or task.get("child_model")
or task.get("model"))
child_effort = (create["effort"]
or task.get("child_effort")
or task.get("effort"))
conn.execute(
"INSERT INTO tasks(id, project_id, prompt,"
" status, idempotency_key, depends_on,"
" priority, created_by, created_at,"
" updated_at, last_heartbeat, executor,"
" model, effort, environment_id,"
" parent_task_id, coordinator_part)"
" parent_task_id, coordinator_part,"
" child_model, child_effort)"
" VALUES(?, ?, ?, 'queued', NULL, '[]',"
" ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, NULL)",
" ?, ?, ?, ?, NULL, ?, ?, ?, ?, ?, NULL,"
" ?, ?)",
(child_id, task["project_id"],
create["prompt"],
task.get("priority", 0) or 0,
task.get("created_by"), now, now,
create["executor"]
or task.get("executor"),
create["model"] or task.get("model"),
create["effort"] or task.get("effort"),
child_model,
child_effort,
task.get("environment_id"),
task["id"]),
task["id"],
task.get("child_model"),
task.get("child_effort")),
)
direct += 1
created += 1
label = create["name"] or "未命名"
model_note = ""
if child_model or child_effort:
model_note = ",模型 %s,强度 %s" % (
child_model or "默认",
child_effort or "默认")
reports.append(
"已创建任务 %s(%s),状态 queued,"
"已创建任务 %s(%s),状态 queued%s,"
"可用 task-poll 按该 id 轮询。"
% (child_id, label))
% (child_id, label, model_note))
conn.commit()
finally:
conn.close()
@@ -3314,9 +3341,9 @@ class Worker:
" idempotency_key, depends_on, priority, created_by,"
" created_at, updated_at, last_heartbeat, executor,"
" model, effort, environment_id, parent_task_id,"
" coordinator_part)"
" coordinator_part, child_model, child_effort)"
" VALUES(?, ?, ?, 'queued', NULL, '[]', ?, ?, ?, ?,"
" NULL, ?, ?, ?, ?, ?, ?)",
" NULL, ?, ?, ?, ?, ?, ?, ?, ?)",
(child_id, task["project_id"], part["prompt"],
task.get("priority", 0) or 0, task["created_by"],
now, now,
@@ -3325,9 +3352,16 @@ class Worker:
# 直接写 part 的 None,子任务会落到 worker
# 默认模型/强度,与父任务的显式选择脱节,
# 既改成本也改行为,且排查时看不出继承关系)。
part.get("model") or task.get("model"),
part.get("effort") or task.get("effort"),
task.get("environment_id"), task["id"], name))
# 派生默认优先于父任务自身:分工显式写 >
# 协调员的 child_model / child_effort >
# 协调员自身的 model / effort。
part.get("model") or task.get("child_model")
or task.get("model"),
part.get("effort") or task.get("child_effort")
or task.get("effort"),
task.get("environment_id"), task["id"], name,
task.get("child_model"),
task.get("child_effort")))
self._audit(
task["project_id"], "coordinator_child_created",
"%s -> %s" % (name, child_id))