Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 70 additions & 13 deletions agent/prompt_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,29 +233,86 @@ def _strip_yaml_frontmatter(content: str) -> str:
"(default 4 hours) when no heartbeat has arrived in the last hour. A "
"reclaim re-queues the task as `ready` without penalty (no failure counter "
"tick), but you lose your current run's progress.\n"
"4. **Block on genuine ambiguity.** If you need a human decision you cannot "
"infer (missing credentials, UX choice, paywalled source, peer output you "
"need first), call `kanban_block(reason=\"...\")` and stop. Don't guess. "
"The user will unblock with context and the dispatcher will respawn you.\n"
"4. **Keep the board moving.** The board is continuously automated: there "
"is no human waiting to shepherd your card. Prefer creating a follow-up "
"card over stopping. Only `kanban_block` under the narrow conditions in "
"\"When `blocked` is the right answer\" below.\n"
"5. **Complete with structured handoff.** Call `kanban_complete(summary=..., "
"metadata=...)`. `summary` is 1–3 human-readable sentences naming concrete "
"artifacts. `metadata` is machine-readable facts "
"(`{changed_files: [...], tests_run: N, decisions: [...]}`). Downstream "
"workers read both via their own `kanban_show`. Never put secrets / "
"tokens / raw PII in either field — run rows are durable forever. "
"Exception: if your output is a code change that needs human review "
"before counting as merged/done (most coding tasks), drop the "
"structured metadata (changed_files / tests_run / diff_path) into a "
"`kanban_comment` first, then end with "
"`kanban_block(reason=\"review-required: <one-line summary>\")` so a "
"reviewer can approve+unblock or request changes. Reviewing-then-"
"completing is more honest than auto-completing work that still needs "
"eyes on it.\n"
"tokens / raw PII in either field — run rows are durable forever.\n"
"6. **If follow-up work appears, create it; don't do it.** Use "
"`kanban_create(title=..., assignee=<right-profile>, parents=[your-task-id])` "
"to spawn a child task for the appropriate specialist profile instead of "
"scope-creeping into the next thing.\n"
"\n"
"## Automated review DAG (code changes)\n"
"\n"
"Reviewable code is reviewed by another agent, not by a human unblocking "
"you. Review is a separate card in the DAG, never a `blocked` state on "
"yours.\n"
"\n"
"**If you are the implementation worker** and your run produced reviewable "
"code:\n"
"1. Create a `ready` review card with "
"`kanban_create(title=..., assignee=<reviewer-profile>, "
"parents=[your-task-id])`. The reviewer profile is normally `pr-reviewer` "
"— it must be a real installed profile (see \"discover profiles first\"). "
"The card is created `ready` so the dispatcher picks it up immediately.\n"
"2. Put exact evidence in the review card body — the reviewer starts cold "
"and must be able to bind the review without guessing: absolute "
"**workspace** path, **repo** path/remote, **base** SHA, **head** SHA "
"(exact, full 40 chars — not a branch name, which moves), branch name, "
"changed files, tests/commands run with results, and the **acceptance** "
"criteria the reviewer should verify against.\n"
"3. Then `kanban_complete(...)` your own implementation card, listing the "
"review card id in `created_cards=[...]`. Your card is done when the "
"review card exists — do not hold it open, and do not block it waiting on "
"the verdict.\n"
"\n"
"**If you are the reviewer**, produce exactly one verdict at the exact head "
"SHA you were given:\n"
"- **PASS** — `kanban_complete(summary=..., metadata=...)` your review "
"card. Nothing else is needed; the DAG is satisfied.\n"
"- **BLOCK** — do NOT `kanban_block`; a rejected review is normal, not a "
"stuck board. `kanban_create` a remediation card assigned to the "
"**original implementation profile** (the assignee of the card under "
"review), with `parents=[your-review-card-id]`, listing every finding as "
"file:line evidence plus the smallest acceptable remediation. Then "
"`kanban_complete` your review card with the verdict, listing the "
"remediation card in `created_cards=[...]`.\n"
"\n"
"**If you are the remediation worker**, fix the findings, then create a "
"**fresh** review card at the new **exact-head** SHA (same evidence "
"contract as step 2 above) and complete your card listing it in "
"`created_cards=[...]`. Never re-open or re-use the old review card — each "
"review binds to one head SHA.\n"
"\n"
"If no valid reviewer profile is installed, do NOT invent an assignee and "
"do NOT self-review: `kanban_comment` the evidence and "
"`kanban_block(reason=\"needs_input: no installed reviewer profile — "
"install/name one\")` so the operator can supply it.\n"
"\n"
"## When `blocked` is the right answer\n"
"\n"
"`blocked` means the board cannot make progress without outside "
"intervention. Use it ONLY for:\n"
"1. **Irretrievable human input** — a decision or secret you cannot infer "
"or discover (missing credentials, a product/UX choice, a paywalled "
"source).\n"
"2. **A hard capability or access wall** — the tool, permission, network, "
"or account simply is not available to you.\n"
"3. **A truly transient failure after retries** — you retried and it still "
"fails for reasons outside the task.\n"
"\n"
"Never use `blocked` as: a dispatcher fence (to stop other work running), "
"a status update (use `kanban_comment`), a review queue (create a review "
"card), an ordinary dependency wait (express it with `parents=[...]`, "
"not `blocked`), or a substitute for child tasks (use `kanban_create`). "
"Dependencies are DAG edges, not blocked state.\n"
"\n"
"## Orchestrator mode\n"
"\n"
"If your task is itself a decomposition task (e.g. a planner profile given "
Expand Down
17 changes: 9 additions & 8 deletions gateway/kanban_watchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,13 @@ def _collect():
msg = f"🔄 {board_tag}{tag}Kanban {sub['task_id']} → {new_status}"
elif kind == "block_loop_detected":
# A task re-blocked for the same cause past the
# recurrence limit and was routed to `triage` for a
# human decision. This is the ONE transition that
# exists to force human attention, yet it emits no
# `blocked`/`status` event — so before adding it to
# TERMINAL_KINDS it produced zero notification and
# the task stalled in triage silently. Ping loudly.
# recurrence limit; the block is now sticky and only
# an explicit unblock resumes it. This is the ONE
# transition that exists to force human attention,
# yet it emits no `blocked`/`status` event — so
# before adding it to TERMINAL_KINDS it produced zero
# notification and the task stalled silently. Ping
# loudly.
reason = ""
recurrences = None
if ev.payload:
Expand All @@ -479,8 +480,8 @@ def _collect():
recurrences = ev.payload.get("recurrences")
rc = f" (blocked {recurrences}x for the same cause)" if recurrences else ""
msg = (
f"🛑 {board_tag}{tag}Kanban {sub['task_id']} routed to TRIAGE"
f" — needs a human decision{rc}{reason}"
f"🛑 {board_tag}{tag}Kanban {sub['task_id']} STUCK BLOCKED"
f" — needs a human decision, unblock to resume{rc}{reason}"
)
else:
# archived / unblocked are claimed by TERMINAL_KINDS
Expand Down
Loading