bug: hook guidance can lead agents to run invalid CLI commands like
Describe the bug In a Claude Code task, a Gortex hook interception/guidance path caused the agent to run a shell command shaped like:
gortex read_file frontend/src/components/reader/V4IdentityPanel.vue 2>&1
This fails with:
Error: unknown command "read_file" for "gortex"
Run 'gortex --help' for usage.
The underlying read_file functionality itself is not broken. The problem is that a hook / adapter guidance path appears to have encouraged a bare MCP tool name to be used as a top-level CLI subcommand.
To Reproduce
- Use Gortex in Claude Code with hooks enabled.
- Let a hook/interception path redirect or guide a source-file read.
- Observe the agent end up running a shell command like:
gortex read_file frontend/src/components/reader/V4IdentityPanel.vue - See the CLI error:
unknown command "read_file" for "gortex"
What I verified locally
gortex --helpdoes not exposeread_fileas a top-level CLI command.- The project guidance in
CLAUDE.mdsays the CLI fallback for arbitrary MCP tools isgortex call <tool>. - This works:
gortex call read_file --arg path=reader/frontend/src/components/reader/V4IdentityPanel.vue --format text - So this looks like a hook/guidance bug, not a daemon or
read_fileimplementation failure.
Expected behavior
If a hook/guidance path suggests a shell fallback, it should emit one of these shapes instead of gortex read_file ...:
gortex call read_file --arg path=reader/frontend/src/components/reader/V4IdentityPanel.vue --format text
Or, better yet, keep the guidance in MCP-tool terms and avoid translating raw MCP tool names into nonexistent top-level CLI verbs.
Why this is confusing The repo guidance is already clear that the two front doors are:
- MCP tool calls
- CLI verbs /
gortex call <tool>for everything else
So when a hook/interception path effectively leads to gortex read_file ..., the agent gets pushed into an invalid CLI shape even though the correct fallback exists.
Related This feels adjacent to #241 (Codex hook effectiveness / hook behavior), but this report is specifically about hook/adaptor guidance producing an invalid CLI command shape for MCP tools.
Environment:
- OS: macOS darwin/arm64
- Go version: go1.26.4
- Gortex version: v0.59.1+00aec84
Additional context Two concrete signals I checked locally:
gortex --helpshowsgortex call <tool>as the generic escape hatch, but no top-levelread_filecommand.gortex call read_file ...succeeds, so the read tool is callable; only the shell command shape is wrong.
Potential fix ideas:
- In hook guidance, never render MCP tool names as bare
gortex <tool>unless there is a real top-level CLI verb. - For generic fallbacks, always render
gortex call <tool> .... - If helpful, the hook could prefer dedicated wrappers where they exist (for example
gortex edit context ...), but should not invent top-level verbs for MCP-only tools.
Consolidating this narrower reproduction into #241 so the hook-related failures stay in one thread.
@Maple0517 I think it's a dedicated issue and it can be related to the https://github.com/zzet/gortex/pull/252 and https://github.com/zzet/gortex/pull/253 changes. After changing the base tools description (and guidance hooks), I started observing (not 100%) similar behaviour.
@zzet Thanks — agreed, this sounds like a dedicated issue.
@Maple0517 is it reproduced for you with a clean install/update (release built for tag), or when it is built from the main branch directly? That main branch contains code which not yet in release.
@Maple0517 main branch updated:
┌──────────────────────────────────────────────────────────┬─────────────────────────────────┬───────────────────────────────────────────┐
│ │ pre-fix │ post-fix │
├──────────────────────────────────────────────────────────┼─────────────────────────────────┼───────────────────────────────────────────┤
│ invalid CLI inventions (degraded condition) │ 13% of sessions │ 0/30 │
├──────────────────────────────────────────────────────────┼─────────────────────────────────┼───────────────────────────────────────────┤
│ sessions answering via gortex vs dodging to git show/sed │ 5/15 │ 15/15 │
├──────────────────────────────────────────────────────────┼─────────────────────────────────┼───────────────────────────────────────────┤
│ gortex call shape discovered │ --help trial-and-error or never │ first-try, 15/15 │
├──────────────────────────────────────────────────────────┼─────────────────────────────────┼───────────────────────────────────────────┤
│ deny-hook fires │ 9/15 │ 1/15 (the policy line pre-empts the path) │
└──────────────────────────────────────────────────────────┴─────────────────────────────────┴───────────────────────────────────────────┘