fix(agent): solve_challenge authorization covers its child's coordinate steps

With only a browser.solve_challenge grant, the vision child run was
denied browser.click_at, so the loop stopped after the first screenshot
(REAL-2 task 4). Steps inside a run spawned by solve_challenge are now
allowed; ancestors' allowlist and step budget still apply. Needs image
rebuild.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-29 03:06:05 +08:00
1 parent bd0e011748
commit 7dc7b1c5fa
3 files changed
+38 -1

No files matched your search

@@ -29,6 +29,9 @@ export const GRANT_ACTIONS: Record<string, readonly string[]> = {
"browser.solve_challenge": ["browser.solve_challenge", "browser.interact"],
};
/** 视觉子流程内由 solve_challenge 授权覆盖的执行类坐标动作 */
const CHALLENGE_STEP_CAPS = new Set(["browser.click_at", "browser.type_at", "browser.scroll"]);
/** 单次审批绑定的计划类型与输入里的计划 ID 字段 */
const APPROVAL_PLAN: Record<string, { planType: string; field: string }> = {
"download.submit": { planType: "acquisition_plan", field: "planId" },
@@ -215,6 +218,13 @@ export function createAuthorizer(deps: {
if (block) return { allowed: false, reason: block };
}
// 视觉子流程(spawn_reason = browser.solve_challenge)里的坐标动作:父会话那次 solve_challenge 已过授权,
// 步数 / 预算 / 白名单由子流程约束,这里随之放行(否则只授权 solve_challenge 时子流程一步也点不了)
if (runId && CHALLENGE_STEP_CAPS.has(d.id)) {
const r = await db.selectFrom("agent_run").select("spawn_reason").where("id", "=", runId).executeTakeFirst();
if (r?.spawn_reason === "browser.solve_challenge") return { allowed: true };
}
// 1) 单次审批
const ap = APPROVAL_PLAN[d.id];
const approvalId = typeof inp.approvalId === "string" ? inp.approvalId : null;