MoonshotAI / MoonshotAI/kimi-code
UserPromptSubmit hooks never fire on goal-continuation turns (origin kind guard)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
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 theUserPromptSubmithook runs ONLY when the prompt origin kind isuser.- 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
UserPromptSubmithook
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):
- Fire
UserPromptSubmitforsystem_triggerorigins whose name isgoal_continuation
(and document the matcher value), or - Add a dedicated
GoalContinuationhook event so consumers opt in explicitly, or - 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read packages/agent-core-v2/src/features/externalHooks/agent/agentExternalHooksService.ts around line 341 and packages/agent-core-v2/src/features/goal/goalService.ts around line 101. Use the existing PromptQueued and TurnStarted hook subscriptions to add a RED regression test for a goal-continuation-shaped prompt. Done means the expected hook behavior is chosen, covered by the test, and any matcher or exclusion is documented as needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100