Repository navigation
Prompt-routing hook ignores words inside backticks (#4564) - #4566
Merged
Merged
Conversation
A prompt that quotes a command in backticks, such as "Run `mycli check` now", was told to run /verify, and a --fix flag or the word broken in a pasted log made a prompt read as a bug report. Triggers and bug-report signs now read only the prose; an exception name in code still marks a bug report. Co-authored-by: vilano93 <[email protected]> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
… with stray backticks no longer stalls the hook A 242 KB prompt with 60 unmatched backtick runs took about 5 s in the routing hook, past its 1.5 s deadline. Each backtick run now looks up its closing run once. Adds tests for a traceback in a fenced block and a helper name such as handleError in code. Review-Finding: p1/specialist-batched#1 reader=red-team Review-Finding: p1/specialist-batched#2 reader=testing Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
5 tasks done
Merged
capy-ai Bot
added a commit
that referenced
this pull request
Nov 20, 2026
- Two /ship approval records stop needing workarounds. (#4549) - For contributors: the paid auto-decide check counts a start step that ran while the skill loaded. (#4543) - The destructive-command check closes three ways past its disk-wipe and force-push blocks. (#4534) - A green CI run still counts when the repository's artifact storage is full. (#4536) - `/cso` now audits repositories that track symlinks. (#4567) - A doc-sync eval stops failing when the audit child drops one field from its result line. (#4555) - The browse daemon no longer picks port 10080, which Chromium refuses to open. (#4554) - Opted-in telemetry now says why a skill run ended, which coding agent and model family ran it, and whether an upgrade worked. (#4542) - A preregistration with only its write-up and plain data now gets the write-up review: one reviewer, one round. (#4544) - When owner rulings don't clear a stopped review, `gstack-review-read` now says which findings are left. (#4553) - The prompt-routing hook now names your installed bug-fix skill on bug reports, alone, and never puts /verify ahead of it. (#4539) - Owner rulings now close a stopped review whose findings were logged in a findings file. (#4568) - /ship can finish after the owner accepts a stopped review's findings as open notes. (#4552) - /ship no longer starts the full test suite on your machine when CI's earlier run can't be reused (GST-3277). (#4565) - The prompt-routing hook no longer acts on words inside backticks. (#4566) - In Claude Code, a gstack skill's start step now runs when the skill loads, so the model can't skip it. (#4509) - gstack's telemetry backend only accepts writes through its own validated endpoint, and the community dashboard now counts real use. (#4537) - gstack now says what it's adding before it adds a background job or a browser extension. (#4538) - For contributors: every flaky pass in Free Tests is now recorded. (#4572) - For contributors: Free Tests on pull requests starts its test shards one round of small jobs sooner. (#4570) - Secret values written as `name=value` at the end of a path are now hidden. (#4571) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Merged
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The prompt-routing hook no longer acts on words inside backticks or code blocks, so a prompt that quotes a command (
Runmycli checknow) stops getting a wrong "run /verify" or "run /review" line.Why: routing is on by default, so any session that quotes commands got these hints; this fixes the report in #4564 by @vilano93, rebuilt on current main.
Nothing to do: plain requests ("run the checks", "review this pr", bug reports in words) route as before.
What changed
Before: a prompt that only quotes a command in backticks was told to run /verify. After: it routes nowhere.
Tests
bun --no-env-file test test/skill-route.test.ts: 31 pass, 0 fail, 331 expect() callsbun run typecheck: cleanBefore/after as text: Before: a prompt that only quotes a command in backticks was told to run /verify. After: it routes nowhere.
People quote commands in backticks all the time, and the routing hook read those words as a request: "Run
gh pr review 123" was told to run /review, and a--fixflag or the word broken in a pasted log made a prompt look like a bug report. The hook now splits a prompt into prose and Markdown code the way CommonMark reads it (inline code spans, fenced blocks with backticks or tildes) and matches triggers and bug-report signs on the prose only. One sign still reads the code, since an exception name such asKeyErroror a pasted traceback still marks a bug report. The split takes a single pass over the prompt, so even a prompt near the hook's 256 KB input limit that is full of stray backticks is handled in milliseconds, well inside the hook's 1.5 second deadline. Claude Code and Codex share the same code, and the docs and changelog say what changed.Why
"Run
mycli checknow" should not be told to run /verify (#4564). With routing on by default, every session that quotes a command could get a wrong skill hint; now only the words around the code decide where a prompt goes.Blast radius
Only
lib/skill-route.tschanged in product code; its callers are the Claude Code and Codex routing hooks andgstack-skill-route --explain, which all read the sameroutePromptresult shape. That is safe because a prompt without backticks or fences takes the same path as before (repro: the full routing test file passes on both hosts, and the new single-pass split matched the earlier regex on 500,000 random strings in two separate fuzz runs).Pre-Landing Review
Two findings in the first review, both below the blocking floor and fixed in 5760b4d: a reviewer finding whose details are recorded privately, and a test gap (no test for a traceback inside a fenced block, and none showing a helper name such as
handleErrorin code is not a bug report), now covered. A follow-up read of the fix found nothing. A second-model adversarial read of the final tree raised four low notes, none blocking; they are listed below.Review notes
Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.
lib/skill-route.ts:272CRLF prompts: FENCE and PARAGRAPH_BREAK do not see \r\n line endings, so a stray backtick can pair across paragraphs and leave prose out of routing (the hint fails open).lib/skill-route.ts:290An unclosed fence or a ~~~~~~~~ separator line sends the rest of the prompt to code; matches CommonMark and the documented behavior.lib/skill-route.ts:297A backslash-escaped backtick opens a code span here, while CommonMark treats it as a literal backtick; a few prose words can be left out of routing.lib/skill-route.ts:355splitCode runs over the whole prompt three times per route (scorePrompt, bugReport, routePrompt); bounded by the 256 KB stdin cap, about 53 ms on 100 KB worst case.Exploratory QA
Surface: the Claude Code routing hook (
hosts/claude/hooks/skill-route-hook.ts), fed hook JSON on stdin with an isolated state root. On the final tree: "run the checks" routes to /verify (capture 008), "Runmycli checknow" routes nowhere (009), and a 242 KB single-paragraph prompt with 60 unmatched backtick runs finishes in 60 ms (010). Before the fix that last prompt took 4954 ms and 5080 ms (006, and its replay 007), past the hook's 1.5 s deadline; that is the defect fixed in 5760b4d. The QA tool reports the run as inconclusive: capture 001 was a malformed first probe (its stdin redirect sat outside the capture, so the hook saw no prompt), and its contract was rerun correctly as 004 and 008. The Codex hook was not probed directly; it shares this code and the test file checks it.Eval Results
No prompt, template, judge or eval-harness file changed, so no paid eval ran. The selector lists 106 behavioral probes that depend on
lib/skill-route.ts; they stay with scheduled and release coverage.Review bot comments
No review bot comments.
Scope Drift
Scope Check: CLEAN
Plan Completion
Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). This is a bug fix, exempt from planning.
Issues
Refs #4564
Refs p1/specialist-batched#1
Refs p1/specialist-batched#2
Verification Results
No plan verification obligations (bug fix, no plan). The failing-first test from #4564 fails on main 92c6c8a and passes here; the new speed test fails on the earlier split (5259 ms) and passes on the final tree.
TODOS
No TODO items completed in this PR.
Documentation
Scope: The committed diff from 92c6c8a to HEAD covers lib/skill-route.ts, test/skill-route.test.ts, docs/skill-routing-and-contracts.md and changelog.d/skill-route-ignores-code-spans.md. Nothing was staged, unstaged or new.
Result: Current, with no edits. The routing doc already explains that triggers and bug-report signs read only the prose and leave out inline code and fenced blocks, with an exception name in code still counting as a bug report. That matches splitCode and EXCEPTION_NAME in the code. The changelog fragment describes the same behavior.
Debt: None found. README.md, docs/skills.md and CLAUDE.md have nothing about routing that this change makes stale.
Agent notes
Outside code: #4564's diff was read as text only; the fix is rewritten on main 92c6c8a. No network, secrets, permissions, workflows, install scripts or dependencies are touched. Issue GST-3292.
Approvals
No approvals recorded for branch skill-route-ignores-code-in-backticks.
Plan: exempt: bug fix with a failing-first test (#4564)
Plan check: exempt bug fix
REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=4 fixed=2 scope=frozen unbound=1 ledgers_read=3 fix_checks=1 dispatches=1
Gate edits: none detected (1 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)