Skip to content

fix(agent-core-v2): fire UserPromptSubmit hooks on goal continuation turns - #4124

Open
haiyu614 wants to merge 2 commits into
MoonshotAI:mainfrom
haiyu614:fix/goal-continuation-user-prompt-submit-hook
Open

haiyu614 wants to merge 2 commits into
MoonshotAI:mainfrom
haiyu614:fix/goal-continuation-user-prompt-submit-hook

Conversation

@haiyu614

@haiyu614 haiyu614 commented Oct 5, 2026

Copy link
Copy Markdown

Goal continuations are submitted as untracked prompts with a system_trigger/goal_continuation origin, so they never reached the prompt-submit gate and the externalHooks origin guard skipped them: UserPromptSubmit never fired for the whole duration of a goal session (#3692).

Two layers actually blocked the hook; both are addressed:

  • loop: the prompt-submit gate now also runs for untracked prompts flagged with the new opt-in UserMeta.gated bit — all other system prompts are unchanged.
  • goal: continuations submit with gated: true. A continuation that a UserPromptSubmit hook blocks no longer stalls the goal silently (gate rejections never produce a TurnEnded); the goal is marked blocked with reason Blocked by UserPromptSubmit hook and stays resumable.
  • external hooks: the origin guard fires UserPromptSubmit for goal_continuation origins, and the payload now includes origin_kind/origin_name so consumers can distinguish continuations from user prompts. Docs (en/zh) updated accordingly.

Covered by two end-to-end tests driving a real hook runner: continuation turns trigger the hook with origin_name: goal_continuation, and a blocking hook (exit 2) marks the goal blocked without any model call.

Fixes #3692

…turns

Goal continuations are submitted as untracked prompts with a
system_trigger/goal_continuation origin, so they never reached the
prompt-submit gate and the externalHooks origin guard skipped them:
UserPromptSubmit never fired for the whole duration of a goal session.

- loop: run the prompt-submit gate for untracked prompts flagged with
  the new UserMeta.gated bit (opt-in, other system prompts unchanged)
- goal: submit continuations with gated: true and settle a continuation
  that a UserPromptSubmit hook blocks by marking the goal blocked
  instead of silently stalling it
- external hooks: fire UserPromptSubmit for goal_continuation origins
  and expose origin_kind/origin_name in the hook payload so consumers
  can distinguish continuations from user prompts

Fixes MoonshotAI#3692
@changeset-bot

changeset-bot Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a19913d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant