Skip to content

fix(agent-hooks): strip Kimi hook-result envelopes - #14791

Closed
bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/14789-kimi-hook-envelope-prompt
Closed

bbingz wants to merge 1 commit into
stablyai:mainfrom
bbingz:fix/14789-kimi-hook-envelope-prompt

Conversation

@bbingz

@bbingz bbingz commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Kimi UserPromptSubmit hook-result envelopes no longer become user prompt text. Strip only complete leading Kimi envelopes, preserve the typed suffix and ordinary inline mentions, and ignore envelope-only events so they cannot replace the last real prompt. Other providers and event kinds retain their existing behavior. The port follows current main's split prompt-fields/provider-dispatch modules. Fixes #14789.

Validation: Cursor's 9 focused vendor tests passed; Codex independently ran all 201 shared hook-listener tests across 16 files. Node non-composite typecheck and changed-file lint/format passed. No live Kimi session was exercised.

Full repository suite/build and default composite typechecks were not run for this candidate. Known baseline TS2883 is not treated as passing; only the explicit non-composite checks above are claimed.

Cursor reviewed the final candidate; Codex independently reviewed the diff and raw checks. Reviewed commit: 68fd42e68b15f58fd74daf633cd7c03d052e5995; rebased onto bba68b1bddf1276c8bd27ad4ca41efcbd4260321.

@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 65362631-ced2-4d4c-865b-de5899fe28dd

📥 Commits

Reviewing files that changed from the base of the PR and between 68fd42e68b15f58fd74daf633cd7c03d052e5995 and a2952e8.

📒 Files selected for processing (1)
  • src/shared/agent-hook-listener.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

Kimi UserPromptSubmit prompt text is normalized by removing leading hook-result envelopes. Submissions that contain only removed content are ignored. Non-empty prompts continue through Kimi normalization, and later tool events reuse the previous accepted prompt. Tests cover envelope removal, empty submissions, prompt reuse, and preservation of ordinary text containing hook-result markup.

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, rationale, linked issue, and validation results, but it omits the required template sections and checklist items, including ELI5, What Changed, Why, Visual Proof w… Rewrite the description using the repository template. Add all required headings and checklist items. Include N/A with a brief reason for Visual Proof because this is not a UI change, and document the omitted full suite, build, and compos…
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: removing Kimi hook-result envelopes from agent hooks.
Linked Issues check ✅ Passed Issue #14789 requires the extracted first prompt to exclude non-content runtime envelopes while preserving the human message. normalizeHookPayload now applies stripLeadingKimiUserPromptHookResults…
Out of Scope Changes check ✅ Passed The changed source files implement Kimi prompt normalization at the extraction boundary and prevent envelope-only status updates. The added tests verify this behavior and provider isolation. These cha…
Full details: Description check

Explanation

The description explains the change, rationale, linked issue, and validation results, but it omits the required template sections and checklist items, including ELI5, What Changed, Why, Visual Proof with N/A, AI Disclosure, Review, Notes, and the final checklist.

Resolution

Rewrite the description using the repository template. Add all required headings and checklist items. Include N/A with a brief reason for Visual Proof because this is not a UI change, and document the omitted full suite, build, and composite typecheck runs under Testing or Notes.

  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@bbingz

bbingz commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded.

Neil closed #14789 on 2026-11-26 as fixed by #34237: Kimi workspace naming keeps only the last assistant record, so hook output no longer lands in the generated branch name. This pull request still strips hook envelopes in the agent-hook listener, and it no longer merges with main.

The fork branch fix/14789-kimi-hook-envelope-prompt remains in place. Reopen this if those envelopes still need to be removed from the listener.

@bbingz bbingz closed this Nov 26, 2026
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.

Branch auto-name ingests agent hook envelopes (<hook_result>, system wrappers) — names anchor on noise

4 participants