You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two related gaps in the hook system prevent plugins from maintaining session
continuity. This affects any plugin that contributes model context —
memory/session-state tools, project-context injectors, or
Claude-Code-compatible hook packs — not one specific plugin.
SessionStart hook output goes nowhere.triggerSessionStart awaits the
hook results and then ignores them
(packages/agent-core/src/session/index.ts). Combined with HookSpecificOutputSchema only parsing message, permissionDecision,
and permissionDecisionReason (session/hooks/runner.ts), a SessionStart
hook has no way to contribute context at all.
Nothing context-capable fires after compaction. SessionStart only
supports startup | resume, and PostCompact is fired via fireAndForgetTrigger with its output discarded
(agent/compaction/full.ts). A plugin that wants to restore session state
after /compact must piggyback on the next UserPromptSubmit — one
message late, and always visible in the TUI, because renderUserPromptHookResult sends the same text to the context and the
display (see also Suggestion: option to hide UserPromptSubmit hook output from TUI #897).
Comparison with Claude Code
Claude Code covers both cases: hookSpecificOutput.additionalContext is
injected into the model context silently (visible to the AI, hidden from the
TUI), and SessionStart fires with source: "compact" right after
compaction. Plugins built for that ecosystem cannot offer equivalent
behavior on Kimi Code today.
Proposal
Either or both, both additive (existing hooks unaffected):
Fire SessionStart with source: "compact" after context.applyCompaction() in full.ts, and route SessionStart hook
output into the rebuilt context. The platform already has an internal
post-compaction injection mechanism (agent.injection.injectGoal()), so
the plumbing partly exists.
Summary
Two related gaps in the hook system prevent plugins from maintaining session
continuity. This affects any plugin that contributes model context —
memory/session-state tools, project-context injectors, or
Claude-Code-compatible hook packs — not one specific plugin.
SessionStart hook output goes nowhere.
triggerSessionStartawaits thehook results and then ignores them
(
packages/agent-core/src/session/index.ts). Combined withHookSpecificOutputSchemaonly parsingmessage,permissionDecision,and
permissionDecisionReason(session/hooks/runner.ts), a SessionStarthook has no way to contribute context at all.
Nothing context-capable fires after compaction. SessionStart only
supports
startup | resume, andPostCompactis fired viafireAndForgetTriggerwith its output discarded(
agent/compaction/full.ts). A plugin that wants to restore session stateafter
/compactmust piggyback on the nextUserPromptSubmit— onemessage late, and always visible in the TUI, because
renderUserPromptHookResultsends the same text to the context and thedisplay (see also Suggestion: option to hide UserPromptSubmit hook output from TUI #897).
Comparison with Claude Code
Claude Code covers both cases:
hookSpecificOutput.additionalContextisinjected into the model context silently (visible to the AI, hidden from the
TUI), and
SessionStartfires withsource: "compact"right aftercompaction. Plugins built for that ecosystem cannot offer equivalent
behavior on Kimi Code today.
Proposal
Either or both, both additive (existing hooks unaffected):
SessionStartwithsource: "compact"aftercontext.applyCompaction()infull.ts, and route SessionStart hookoutput into the rebuilt context. The platform already has an internal
post-compaction injection mechanism (
agent.injection.injectGoal()), sothe plumbing partly exists.
hookSpecificOutput.additionalContextas a silent injectionchannel (AI-visible, TUI-hidden) for all hook events — this would also
resolve Suggestion: option to hide UserPromptSubmit hook output from TUI #897.
Source references
packages/agent-core/src/session/index.ts—triggerSessionStart(source: 'startup' | 'resume'), results unusedpackages/agent-core/src/session/hooks/runner.ts—HookSpecificOutputSchemapackages/agent-core/src/session/hooks/user-prompt.ts—renderUserPromptHookResultpackages/agent-core/src/agent/compaction/full.ts—triggerPostCompactHookviafireAndForgetTriggerRelated: #897 (hide UserPromptSubmit hook output from TUI), #447 (session
lifecycle hooks).
Happy to send a PR with whichever option you prefer.