feat: run fixed research pipelines within durable budgets

This commit is contained in:
yuxuanhui
2026-09-08 22:16:05 +08:00
parent eb4850a003
commit 7860434b04
25 changed files with 2357 additions and 37 deletions
+44
View File
@@ -160,3 +160,47 @@ CAPABILITIES += (
handler=lambda ctx, args: Evaluations(ctx.business.db).create(args),
),
)
class FlowReference(Contract):
run_id: str = Field(min_length=1, max_length=36)
class FlowQuery(Contract):
limit: int = Field(default=25, ge=1, le=100)
offset: int = Field(default=0, ge=0)
async def read_flow(ctx, args):
from .workflows import Workflows
return await Workflows(ctx.business.db).get(args.run_id)
async def list_flows(ctx, args):
from .workflows import Workflows
return await Workflows(ctx.business.db).list(args.limit, args.offset)
CAPABILITIES += (
Capability(
name="get_research_run",
schema=FlowReference,
description="读取研究运行的固定授权、预算、阶段和产物,不能启动或扩大研究。",
label="读取研究运行",
renderer="research",
effect="query",
handler=read_flow,
),
Capability(
name="list_research_runs",
schema=FlowQuery,
description="分页查看已有研究运行。",
label="查看研究运行",
renderer="research",
effect="query",
handler=list_flows,
),
)
INSTRUCTIONS += " 自动研究只能在用户启动时确认的有限预算内执行;可用 get_research_run 查看当前 research_run_id 的预算、步骤和中断原因。普通 Chatbox 不授予自动研究执行权限。"