fix(kanban): nudge workers that exit without complete/block

Add a bounded turn-end stop guard for kanban workers. When a worker
tries to exit with finish_reason=stop without having called
kanban_complete or kanban_block, inject up to two synthetic nudges
so the conversation loop continues instead of exiting cleanly (which
the dispatcher records as protocol_violation).

Mirrors the existing verify-on-stop pattern: same ephemeral scaffolding
flag (_kanban_stop_synthetic), same role-alternation contract, same
_pending_verification_response fallback for budget exhaustion.

Disabled by default (gated on HERMES_KANBAN_TASK env var set by the
dispatcher); kill switch via HERMES_KANBAN_STOP_NUDGE=0.

Salvaged from #62262 by @mdc2122. The original branch was 272 commits
behind main with ~538 files of stale-base reversions; this salvage
applies only the 4 substantive files (agent/kanban_stop.py,
conversation_loop.py insertion, run_agent.py _EPHEMERAL_SCAFFOLDING_FLAGS,
tests/agent/test_kanban_stop.py).
This commit is contained in:
mdc2122 2026-07-14 16:25:53 +05:30 committed by kshitij
parent 3c2886f599
commit 03fbf6edbb
4 changed files with 251 additions and 0 deletions

View file

@ -232,6 +232,8 @@ _EPHEMERAL_SCAFFOLDING_FLAGS = (
# transcript and breaks prompt-prefix cache reuse on later turns. (#55733)
"_verification_stop_synthetic",
"_pre_verify_synthetic",
# kanban worker stop-guard: narrated exit without kanban_complete/block
"_kanban_stop_synthetic",
)