Skip to content

Claude Code Opportunity: Use prompt hook on Stop for task completion verification #630

@Wirasm

Description

@Wirasm

Context

Currently when a worker agent stops, the shell hook forwards a [DONE] message to the honryu brain, which then decides whether the task was actually completed or needs more work. This adds latency and brain cognitive load.

Opportunity

Claude Code now supports type: "prompt" hooks — a single-turn LLM call that returns {ok: true/false, reason}. On Stop events, if ok: false, Claude continues working instead of stopping, with the reason fed back as context.

{
  "Stop": [{
    "hooks": [{
      "type": "prompt",
      "prompt": "The agent was assigned the following task:\n\n$TASK_CONTENT\n\nThe agent's last message was: $ARGUMENTS\n\nDid the agent fully complete the task? Return {\"ok\": false, \"reason\": \"what remains\"} if not done.",
      "timeout": 30,
      "statusMessage": "Verifying task completion..."
    }]
  }]
}

Benefits

  • Catches incomplete work before it reaches honryu brain
  • Reduces brain workload (only truly completed tasks get forwarded)
  • Agents self-correct without human intervention
  • Uses stop_hook_active guard to prevent infinite loops (Claude Code sets this on re-entry)

Considerations

  • The prompt hook has access to last_assistant_message in the input JSON — useful for evaluation
  • stop_hook_active: true is set when Claude is already continuing due to a Stop hook — must check this to avoid infinite loops
  • Cost: each Stop event triggers an LLM call (Haiku-level, ~30s timeout)
  • Could also use type: "agent" for deeper verification (50 turns, can Read/Grep files)
  • Need to inject the dropbox task content into the prompt somehow (env var or file read)

Files involved

  • crates/kild-core/src/sessions/integrations/claude.rs — settings patching
  • crates/kild-core/src/sessions/dropbox.rs — dropbox protocol (task content)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority - Backlog, when time permitseffort/lowSingle file or function, one responsibility, isolated changefeatureNew functionality (planned)fleetFleet/brain (Honryū) coordination

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions