feat(kanban): goal_mode cards run workers in a /goal loop (#35710)

* feat(kanban): goal_mode cards run workers in a /goal loop

A goal_mode card wraps its dispatched worker in the Ralph-style goal
loop behind /goal: after each turn an auxiliary judge checks the
worker's response against the card title+body, and if not done the
worker keeps going in the SAME session until the judge agrees, the
worker terminates the task itself, or the turn budget runs out (which
blocks the card for human review — never a silent exit).

- kanban_db: goal_mode + goal_max_turns columns (additive migration),
  Task fields, create_task params, INSERT wiring, created-event payload.
- kanban_tools: goal_mode/goal_max_turns on the kanban_create tool so
  orchestrators can opt cards in when fanning out.
- kanban CLI: --goal / --goal-max-turns on 'kanban create'.
- dashboard API: goal_mode/goal_max_turns on the create endpoint
  (auto-surfaced back via asdict).
- _default_spawn: sets HERMES_KANBAN_GOAL_MODE / _GOAL_MAX_TURNS only
  when the card opts in.
- goals.run_kanban_goal_loop: standalone, callback-injected loop engine
  (no SessionDB persistence; ephemeral worker). cli.py quiet path calls
  it after the worker's first turn when the env vars are set.
- Docs: orchestrator skill + kanban feature page.

Tests: DB roundtrip + legacy migration, spawn env gating, and the loop's
continuation/completion/budget-block/finalize-nudge branches. E2E run
against a real kanban DB confirms a budget-exhausted goal worker lands
in a sticky blocked state.

* feat(kanban/dashboard): goal-mode toggle in the create form

Wires the goal_mode card setting into the dashboard UI (the plugin's
hand-written IIFE bundle, no build step):

- InlineCreate: 'goal mode' checkbox after the skills field; checking it
  reveals an optional 'max turns' number input. Both reset on submit and
  only post goal_mode/goal_max_turns when enabled.
- TaskDrawer: a 'Goal mode: on (max N turns)' MetaRow so a card's
  goal-mode setting is visible after creation (auto-fed by asdict via the
  existing _task_dict).

Live-tested through the running dashboard with a browser: created a
goal-mode card with max-turns=8, confirmed it persisted to the kanban DB
(goal_mode=1, goal_max_turns=8) and rendered back in the drawer as
'on (max 8 turns)'. No JS console errors.
This commit is contained in:
Teknium
2026-05-31 01:16:33 -07:00
committed by GitHub
parent 32899279a7
commit 0cd7d54b00
10 changed files with 744 additions and 2 deletions

View File

@ -759,6 +759,10 @@ def _handle_create(args: dict, **kw) -> str:
return tool_error(
f"skills must be a list of skill names, got {type(skills).__name__}"
)
goal_mode, goal_bool_error = _parse_bool_arg(args, "goal_mode")
if goal_bool_error:
return tool_error(goal_bool_error)
goal_max_turns = args.get("goal_max_turns")
if isinstance(parents, str):
parents = [parents]
if not isinstance(parents, (list, tuple)):
@ -786,6 +790,10 @@ def _handle_create(args: dict, **kw) -> str:
if max_runtime_seconds is not None else None
),
skills=skills,
goal_mode=goal_mode,
goal_max_turns=(
int(goal_max_turns) if goal_max_turns is not None else None
),
initial_status=str(initial_status),
created_by=os.environ.get("HERMES_PROFILE") or "worker",
session_id=session_id,
@ -1250,6 +1258,29 @@ KANBAN_CREATE_SCHEMA = {
"assignee's profile."
),
},
"goal_mode": {
"type": "boolean",
"description": (
"Run the dispatched worker in a goal loop. When true, "
"after each turn an auxiliary judge checks the worker's "
"response against this card's title/body; if the work "
"isn't done and budget remains, the worker keeps going "
"in the same session until the judge agrees it's "
"complete (or the goal-turn budget is exhausted, which "
"blocks the task for human review). Use this for "
"open-ended cards where one shot rarely finishes the "
"work. Defaults to false (classic single-shot worker)."
),
},
"goal_max_turns": {
"type": "integer",
"description": (
"Turn budget for goal_mode workers. Caps how many "
"continuation turns the worker may take before the task "
"is blocked for review. Ignored unless goal_mode is "
"true. Defaults to the goal-engine default (20)."
),
},
"board": _board_schema_prop(),
},
"required": ["title", "assignee"],