Skip to content

fix(issue-triage): forbid stdin redirection with bridged gh CLI - #943

Merged
dcramer merged 1 commit into
mainfrom
cursor/fix-issue-triage-stdin-hang-b753
May 8, 2026
Merged

dcramer merged 1 commit into
mainfrom
cursor/fix-issue-triage-stdin-hang-b753

Conversation

@dcramer

@dcramer dcramer commented May 8, 2026

Copy link
Copy Markdown
Member

What

Tighten the issue-triage skill prompt so the agent never tries to feed input into gh via shell stdin redirection or --body-file -.

Why

Run 25576059392 hung for 5 minutes and then failed during the apply-triage-update stage:

21:08:53 [flue] tool:start  bash  $ gh issue edit 941 --repo getsentry/sentry-mcp --body-file - < /workspace/issue-941-body.md && gh issue view 941 ...
21:13:53 [flue] Agent error: terminated

The agent had already run a successful gh issue edit ... --body-file /workspace/issue-941-body.md --title "..." a few seconds earlier, then re-ran the edit using --body-file - to "verify" the result. That second invocation hung until the 5-minute stage timeout, and along the way wiped the body of issue #941 to an empty string.

Root cause

The agent shells out through Flue's defineCommand:

const gh = defineCommand("gh", {
  env: { GH_TOKEN: process.env.GH_TOKEN ?? process.env.GITHUB_TOKEN },
});

The env form in @flue/sdk/dist/node/index.mjs runs commands via child_process.execFile(name, args, mergedOpts) — it never forwards stdin from the simulated just-bash shell into the spawned process. When the model uses shell redirection (< file) or --body-file -, the redirected bytes are read by the simulated shell and then dropped on the floor; the real gh process is launched with an unwritten stdin pipe and blocks on read() forever.

just-bash is itself a "simulated bash environment with virtual filesystem" (see the package README), so any feature that depends on the OS shell forwarding stdin into a bridged binary is unsafe.

Fix

Update .agents/skills/issue-triage/SKILL.md to make the limitation explicit, since this is a prompt-level mitigation:

  • New "Shell sandbox limits" subsection in the global rules forbidding stdin redirection (<, <<, <<<), process substitution, and --body-file - / --body - against any bridged command (gh, git, ...).
  • apply-triage-update and close-duplicate stages now require:
    • Writing the body/comment to a real file path first (e.g. /workspace/issue-<n>-body.md).
    • Always passing it via --body-file <path>.
    • Running each gh mutation in its own bash invocation (no && chains with verification reads).
    • Trusting a successful gh issue edit exit code instead of re-running it to verify, which is exactly what triggered the hang.

Notes / follow-ups

  • The body of issue Rename MCP skills to toolsets and support finer-grained tool access controls #941 is currently empty because of this bug. The cloud agent does not have issues:write, so I could not restore it from this branch — a maintainer should re-run the triage agent (or paste the proposed body back manually) once this lands.
  • A more thorough fix would be to make defineCommand properly forward just-bash's stdin into execFile, but that's an upstream @flue/sdk change. The SKILL update is a defensive mitigation that prevents the failure mode regardless.
  • I considered also enforcing this at the defineCommand layer (e.g. wrapping gh to reject --body-file -), but the function-form defineCommand in flue 0.3.11 only receives args (not the bash ctx), so we can't currently do that without forking the wrapper.

Quality gate

  • pnpm run lint ✅
  • pnpm run tsc ✅
  • pnpm run test not run — change is prompt-only and there are no tests covering the SKILL prose. The triage agent is exercised end-to-end on the next opened issue.

Slack Thread

Open in Web Open in Cursor 

The flue `defineCommand` shim used to expose `gh` and `git` to the
agent runs commands via `child_process.execFile` and never forwards
just-bash's stdin into the spawned process. When the issue-triage
agent ran `gh issue edit ... --body-file - < /workspace/...md` (run
25576059392), `gh` blocked on an unwritten stdin pipe until the
5-minute stage timeout fired. The mutation also wiped the body of
issue #941 to an empty string before the kill.

Update the issue-triage skill so the model:

- Treats stdin redirection (`<`, `<<`, `<<<`) and `--body-file -`
  as forbidden when invoking bridged commands.
- Always passes content via a real file path (`--body-file <path>`).
- Runs each `gh` mutation in its own bash invocation and never
  chains an edit with a verification call.
- Trusts a successful `gh issue edit` instead of re-running it to
  verify, which is what triggered the second, hanging call.

Co-Authored-By: Cursor Agent <[email protected]>
@dcramer
dcramer marked this pull request as ready for review May 8, 2026 21:24
@dcramer
dcramer merged commit 9e0c69b into main May 8, 2026
13 checks passed
@dcramer
dcramer deleted the cursor/fix-issue-triage-stdin-hang-b753 branch May 8, 2026 21:25
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.

2 participants