From dd8485b7e2bd74377337ce00096bc6abcfb1cb9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Sun, 19 Apr 2026 19:23:37 -0400 Subject: [PATCH] Surface the CEO self-review guard as a proper 422 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The database layer already refuses to advance a top-level assignee's task to in_review without requires_user_review=1 — the right invariant. But the HTTP route caught nothing specific and returned a bare 500, so the CEO prompt had to carry a paragraph of "the system will demote any such task back to todo, but the cycle wastes a heartbeat slot" prose to keep the model away from the error path. Translate the guard to a 422 NO_REVIEWER_ON_TOP_LEVEL_TASK response with an actionable hint and rewrite the prompt section to describe the contract instead of begging the model to avoid the failure. Also drop the residual skill-looping paragraph now that hires get their default kit on approval. --- src/main/api-server/routes-tasks.ts | 11 +++++++++++ src/main/prompt-builder/ceo-modes/team-building.en.md | 10 +++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/api-server/routes-tasks.ts b/src/main/api-server/routes-tasks.ts index eaf45852..3dfafa41 100644 --- a/src/main/api-server/routes-tasks.ts +++ b/src/main/api-server/routes-tasks.ts @@ -278,6 +278,17 @@ export function registerTaskRoutes(server: AgentApiServer) { server.json(res, 404, { error: error.message }); return; } + // Top-level assignee self-review guard: translate to a 422 so the + // agent sees an actionable business-logic rejection rather than a + // generic server failure. + if (error instanceof Error && error.message.includes("cannot enter in_review")) { + server.json(res, 422, { + error: error.message, + code: "NO_REVIEWER_ON_TOP_LEVEL_TASK", + hint: "Either reassign the task to a report, mark it done directly if the work is complete, or set requires_user_review=1 if the Board should review.", + }); + return; + } server.json(res, 500, { error: error instanceof Error ? error.message : "Task update failed" }); } }); diff --git a/src/main/prompt-builder/ceo-modes/team-building.en.md b/src/main/prompt-builder/ceo-modes/team-building.en.md index 2e51cbfe..d8320708 100644 --- a/src/main/prompt-builder/ceo-modes/team-building.en.md +++ b/src/main/prompt-builder/ceo-modes/team-building.en.md @@ -35,11 +35,7 @@ For each role chosen in Step 2, `POST /api/companies/{companyId}/agents` with: - `budgetMonthlyUsd`: 50–250 per agent - `model`: pick per role complexity -After each hire is approved (`hire_agent` auto-approves when company policy allows), assign skills: - -1. `GET /api/companies/{companyId}/skills` to review options. -2. For every relevant skill: `POST /api/agents/{agentId}/skills` with `{"skillId": ""}`. -3. Match skills to role — engineering skills to engineers, writing/marketing skills to writers, etc. +Default domain skills are assigned automatically the moment a hire is approved — do not loop over skills unless you want to override the defaults for a specific agent. **You must submit every intended hire before you consider Step 4.** @@ -53,9 +49,9 @@ Once — and only once — all hire requests for this wake are live, `POST` one Do not submit this approval more than once per team-building phase. If it exists already (pending or approved), you are finished here. -## Self-assignment: do not do it +## Self-assignment is rejected at the API -Do **not** assign large goal-level tasks to yourself and move them to `in_review`. You have no manager; no one can review you. The system will demote any such task back to `todo` on the next boot, but the cycle wastes a heartbeat slot. Instead: create the task with an assignee from Step 3's hires, or leave it unassigned for the auto-assign rule to pick up. +Attempts to move a task you own to `in_review` without a reviewer return `422 NO_REVIEWER_ON_TOP_LEVEL_TASK` — the error response carries the options. Assign the task to one of your hires from Step 3 instead, or mark it directly `done` when the work is genuinely complete. ## End state for this wake