[Graphite MQ] Draft PR GROUP:spec_c00243 (PRs 38) - #47
Closed
graphite-app[bot] wants to merge 1 commit into
Closed
graphite-app[bot] wants to merge 1 commit into
graphite-app[bot] wants to merge 1 commit into
Conversation
## Summary Claude Code runs any Bash command that contains a heredoc with stdin connected to a Unix socket. It never writes to that socket and never closes it; commands without a heredoc get `/dev/null` instead. vf took the socket for a piped body. Every body command in such a call waited the full 10s stdin deadline and then failed, even with every field given as a flag. An agent then had to retry with `</dev/null` and remember to add it to every later write. In agent mode, a socket on stdin that delivers nothing within 250ms is now taken to carry no body. Pipes and files keep the full 10s in every mode. Shells hand vf a pipe for `producer | vf` and a file for redirects and heredocs, never a socket. So slow producers (`curl … | vf`) and the README's "pipe a body, override fields with flags" still work. A socket comes from a program that spawned vf, and a program that means to send a body writes it as it starts vf: a Node parent's first byte arrives within 0.1ms, even with 100 spawns at once. The `output` package owns agent detection and imports `flagutil`, so `flagutil` cannot import it to ask. Instead `output` installs `IsAgentMode` in `flagutil` when the program starts (`internal/output/agentmodecheck.go`), and `flagutil` asks it each time rather than keeping a copy. So the stdin rule follows however agent mode is finally resolved, including an explicit `--agent-mode` once the separate fix for that flag lands. ## Options compared Each option was measured against the existing stdin tests plus the four new cases: | Option | Silent socket no longer stalls | Slow piped body still read | |---|---|---| | Skip stdin when flags satisfy the body | only when a body flag is given | no: dropped when flags are also given (a README case) | | Short window for any stdin, agent mode | yes | no: slow pipelines dropped in agent mode | | Skip stdin that is not yet readable | yes | no: python3, node and slow producers dropped (5 tests fail) | | **This PR: short window for a socket, agent mode** | **yes** | **yes (13/13)** | Deliberate limit: an idle *pipe* in agent mode still waits 10s, because a pipe is also how a slow `producer | vf` arrives. Claude Code does not hand vf one. ## Before and after `vf agent update --prompt x`, run in an agent's Bash call that contains a heredoc: | | master | this PR | |---|---|---| | Time | 10.0s | 0.8s | | Result | `failed to read stdin: timed out…`, exit 1 | prompt sent, exit 0 | ## Test plan - [x] `gofmt`, `go vet ./...` and `go test ./...` pass; `go.mod` is unchanged. - [x] `internal/flagutil/stdin_test.go` covers the decision rule and the bounded read: - a silent reader means no body; - a body that starts in time is read; - the first bytes, then the rest, are both read; - EOF returns at once; - a slow body with no limit is read. - [x] `test/stdin-handling.test.ts` has 4 new cases, and the file passes 13/13: - a silent socket returns at once, with flags and without (both take 10s and fail on master); - a socket that writes at spawn is still read; - a slow shell producer merged with flags is still read. - [x] Reproduced and verified inside a real Claude Code Bash call. - [ ] CI The 4 vitest cases that already fail on master (`docs-command` ×2, `flag-errors`, `flag-raw-text`) are fixed by #37. With both PRs applied to current master, the suite passes 82/82.
graphite-app
Bot
deleted the
gtmq_spec_c00243_1790966144850-d53d03ac-ca33-45a5-9443-69cc852ef8e7
branch
October 2, 2026 18:36
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.
This draft PR was created by the Graphite merge queue.
Trunk will be fast forwarded to the HEAD of this PR when CI passes, and the original PRs will be closed.
The following PRs are included in this draft PR: