Skip to content

UserPromptSubmit hooks never fire on goal-continuation turns (origin kind guard) #3692

Description

@mikkihugo

Component: agent-core-v2 external hooks + goal feature

Observed (verified on latest main 7f5debf, also present in released 0.41.0):

  • packages/agent-core-v2/src/features/externalHooks/agent/agentExternalHooksService.ts:341:
    if ((ctx.promptMessage.origin ?? USER_PROMPT_ORIGIN).kind !== 'user') return false;
    so the UserPromptSubmit hook runs ONLY when the prompt origin kind is user.
  • Goal continuations are submitted with a different origin —
    packages/agent-core-v2/src/features/goal/goalService.ts:101:
    { kind: 'system_trigger', name: 'goal_continuation' }.
  • Therefore during goal mode every auto-continuation turn skips the UserPromptSubmit hook
    entirely, however long the goal runs.

Impact: hooks configured on UserPromptSubmit (mailbox sweeps, session-facts injection,
input gating, metrics) silently never fire for the whole duration of a goal session, which is
exactly the mode where the machine is meant to work unattended. There is no other hook event
that fires per goal turn (PreToolUse/PostToolUse fire only when tools run; Stop/
PreCompact are turn/compaction-adjacent and do not carry prompt input).

Suggested fix (any of):

  1. Fire UserPromptSubmit for system_trigger origins whose name is goal_continuation
    (and document the matcher value), or
  2. Add a dedicated GoalContinuation hook event so consumers opt in explicitly, or
  3. Document this exclusion in the hooks reference so consumers can choose PostToolUse
    instead.

Test seam exists: the hook service already subscribes to PromptQueued and TurnStarted;
a RED test asserting the hook runs on a goal-continuation-shaped prompt would cover it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions