Repository navigation
Conversation
The tag matcher did not allow underscores, so the Kimi UserPromptSubmit envelope was never classified as machinery and replaced the user's real prompt. Branch auto-naming then anchored on the envelope instead of the task. Fixes stablyai#14789
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe change updates leading harness tag detection to allow underscores and adds Merge Risk: ⚪ Minimal · up to This localized change correctly preserves the user’s prompt when processing Kimi hook envelopes without changing supported user-tag behavior. No actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
ELI5
When you type a request to Kimi, its hook sends Orca a second, robot-written message right after yours:
<hook_result hook_event="UserPromptSubmit">{}</hook_result>. Orca already knows how to ignore robot messages like this, but it was only recognising the ones written with dashes (<system-reminder>), not the ones with underscores. So the robot message overwrote what you actually typed, and the branch got named after the robot message instead of your task.What Changed
src/shared/harness-injected-user-turns.ts:_as well as-, so<hook_result ...>is seen as a tag at allhook_resultadded toKNOWN_HARNESS_TAG_NAMESBoth are needed: the regex alone would not classify it, and the allowlist entry alone is unreachable because the regex never matches the name.
Why
resolvePromptinagent-hook-listener.tskeeps the cached prompt whenisKnownHarnessInjectedUserTurnTextreturns true. That classifier's tag matcher was/^<([a-z][a-z0-9-]*)(?:[\s>]|$)/, which cannot matchhook_result, so the envelope was treated as a genuine user turn and replaced the real prompt.buildBranchNamePromptthen received the envelope asfirstPrompt.I kept the allowlist approach rather than matching underscore tags generically, because the file's own comment warns that Grok wraps real typed prompts in
<user_query>. Treating the underscore shape itself as machinery would misclassify those. Only the name that was actually observed is added, and there is a test asserting<user_query>and<my_widget>still count as user turns.Linked Issue
Fixes #14789
Visual Proof
N/A- no UI or interaction change. The only visible difference is the generated branch name, which is model output and therefore not stable enough to screenshot meaningfully. The behavioural change is shown by the test below instead.Testing
Reproduced through the listener before fixing, using the existing Kimi test harness. A typed prompt followed by the envelope:
Two tests added:
agent-hook-listener-claude-compatible-vendors.test.ts- the end-to-end one, next to the existing Kimi harness-injection test. Asserts the cached prompt survives the envelope.harness-injected-user-turns.test.ts- classifier level, including the<user_query>/<my_widget>non-regression.Each half of the fix was reverted independently; both mutations fail both tests:
vitest run src/shared/is 4772 passed, 2 failed. Both failures are pre-existing and unrelated (automation-schedulesexpectsSundaysand getsSonntagson a non-English locale;external-automation-jobs-fileexpects a different error string). Both fail identically with my change stashed. All threetypecheckprojects andoxlint src/shared/are clean.Platforms: pure string classification, no platform, path, shell, or network behaviour. Tested on Linux.
AI Disclosure
Written with AI assistance (Claude Code, Opus 5). I reproduced the bug through the listener, confirmed the two pre-existing test failures are unrelated by stashing, and ran the mutation checks.
Review
harness-injected-user-turns.tsis insrc/shared/, so local and SSH targets get identical classification, which is the point of it living there.hook_resultis added to the same observed-shapes allowlist every other harness uses, not behind a Kimi-specific branch, so any harness emitting the same envelope benefits. Grok's<user_query>is explicitly protected by test.Setlookup.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author