Surface the CEO self-review guard as a proper 422
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.
This commit is contained in:
1 parent
0443b4a197
commit
dd8485b7e2
2 files changed
+14
-7
No files matched your search
@@ -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" });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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": "<id>"}`.
|
||||
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
|
||||
|
||||
|
||||
Reference in new issue
Block a user