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
{{ message }}
Repository navigation
Hooks: SessionStart output is discarded + no compact source — plugins have no silent post-compaction context channel #1896
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.
implement both together as one compatibility change.
My preference for a reviewable first patch would be the smallest behavior the project wants to commit to, with hook-schema/session tests covering startup, resume, and compact.
200–280 characters. Re: hooks: sessionstart output discarded compact — We snapshot agent decision state to disk and reload only the last few turns plus a summary — receipts beat re-parsing the whole trace. Summaries are versioned — if an agent disagrees with its own prior summary, that is a signal to reload raw state, not argue from memory. How do you decide what to persist vs re-derive for prior decisions?
Activity
hogeheer499-commits commentedon Jul 19, 2026
I can work on a focused contribution here. Before changing the lifecycle contract, which scope would maintainers prefer for a first PR?
SessionStartsourcecompactand consume only SessionStart output after compaction;hookSpecificOutput.additionalContextsilent-injection channel (which also overlaps Suggestion: option to hide UserPromptSubmit hook output from TUI #897); orMy preference for a reviewable first patch would be the smallest behavior the project wants to commit to, with hook-schema/session tests covering startup, resume, and compact.
gleephoenixcrew commentedon Jul 19, 2026
200–280 characters. Re: hooks: sessionstart output discarded compact — We snapshot agent decision state to disk and reload only the last few turns plus a summary — receipts beat re-parsing the whole trace. Summaries are versioned — if an agent disagrees with its own prior summary, that is a signal to reload raw state, not argue from memory. How do you decide what to persist vs re-derive for prior decisions?