Skip to content

Intermittent: post-action hook messages missing from the next-turn request after session resume (pre-action always delivered) #4174

Description

@Einherjare

Summary

A conformance rig that drives kimi headless (CLI, print/headless mode with session resume) observes that post-action hook messages are intermittently not delivered to the next turn, while pre-action hook messages are always delivered. The delivery mechanism itself works when the messages do arrive (user-role hook_result).

Scenario

  • An external harness launches kimi headless against a scratch project with hooks configured.
  • Hooks run checks around tool calls:
    • a pre-action check (before Write|Edit) that must stay silent in the turn it fires and appear in the next turn's request body as a user-role hook_result message ("before Write");
    • a post-action check (after Write|Edit) with the same held-delivery contract ("after Edit");
    • a post-guard on Bash with the same contract ("after Bash").
  • The harness launches a session, then resumes it (--resume <session_id>, headless) and inspects the outgoing request bodies.

Observed

Seven assertions per run; six are consistently green. The intermittent one is the post-action Write|Edit warning:

Check Result
pre-action warning delivered next turn ("before Write") ✅ always
post-action warning delivered next turn ("after Edit") ❌ intermittent
post-action Bash warning delivered next turn ("after Bash") ✅ in 3 of 4 failing runs (failed once alongside the Edit check)
delivered as user-role hook_result ✅ when present
silent in the turn they fire ✅

Timeline (all runs on the identical binary, same sha256):

  • 2026-10-08 06:13 UTC — post-action Edit check failed
  • 2026-10-08 06:16 UTC — same tree, same binary: all 7 passed
  • 2026-10-11 02:04 / 02:06 / 02:07 UTC — three consecutive runs on two different source trees (one of them a clean control tree): same single check failed each time

The two source trees differ substantially; the failure signature is identical and binary-independent.

Environment

  • @moonshot-ai/kimi-code v2.1.1, Linux x64
  • binary: /usr/bin/kimi → dist/main.mjs
  • sha256 2563a338c94868a34e1bfd2e5579067d5a472acf4cb0bf350a3bfe1092bbe59d (identical across every pass and fail above; installed 2026-10-08 00:33 +0200, so the 10-08 pass and fail ran on this same build)

Expected vs actual

  • Expected: held post-action warnings always appear in the next turn's request after resume, as user-role hook_result.
  • Actual: the post-action ("after Edit") warning is sometimes absent from the next-turn body; the pre-action one is never absent.

Notes

  • Since the binary is unchanged between pass and fail, the nondeterminism likely sits in the message-assembly/resume path — possibly influenced by model/server-side behavior — rather than in local code.
  • Possibly related: UserPromptSubmit hook output hides user messages from chat history (desktop, Windows) #4132 (UserPromptSubmit hook output and chat-history visibility) — different surface (headless resume vs desktop TUI), same neighborhood of hook-output handling.
  • I can provide redacted request/response captures from failing and passing runs on request; the harness is private, but the wire-level evidence is exportable.

Thanks for taking a look — this one intermittently blocks a release gate that requires an all-green run.

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