Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix(cli): proxy reads stdin only with -d -, execute fails on a silent stdin pipe (#5466)
## Why Agents calling `composio proxy` to the Gmail and Drive APIs saw some calls hang for minutes with no output, while identical calls returned normally. The agent waited instead of timing out. The ask was to fix the CLI so these calls stop hanging silently. Server logs show every proxy call that reached the backend returned in under a second, and no request arrived while the agent was stuck. So the hang happened in the CLI, before any request was sent. ## Root cause Without `-d`, `composio execute` and `composio proxy` read stdin whenever it is not a terminal, waiting for end of input with no timeout. Agent harnesses often run commands with a stdin pipe they never write to or close, so the command blocked before sending anything. ## Fix An earlier revision of this PR treated a pipe that stayed silent for 1 second as no input. Review pointed out that this trades the hang for silent data loss: `execute` could run a tool with `{}` while its arguments were still on their way. This revision takes a different approach: - **`proxy`** reads a request body from stdin only with `-d -` (or `-d @-`). Without `-d` it never touches stdin, so a proxied GET returns at once. This removes the root cause rather than bounding it. - **`execute`** still reads piped JSON without `-d`, since that is documented. A pipe that sends nothing within 1 second (`PIPED_STDIN_SILENCE_TIMEOUT`) now fails with `No input arrived on stdin within 1 second. Pass the arguments with -d '{...}', or -d - to wait for stdin.` and exits 1, without running the tool. - **`-d -`** (and `-d @-`) still waits for stdin as long as it takes, for both commands. - **`listen`** resolves `-p` through the explicit path. It never used the implicit stdin read. The trade-off: `slow_cmd | composio execute X` with no `-d`, where the first byte takes over a second, now fails and says to pass `-d -`. That is the behavior review asked for, in place of running the tool without arguments. ## Tests - `test/src/services/stdin.test.ts` drives the real reader (`readStdinToEnd`) over a `PassThrough` with fake timers: - a silent pipe gives up at the timeout - a first byte after the timeout gives up and leaves the data unread - empty end of input returns an empty string - data before the timeout is read to a late end of input - with no timeout, it waits for a late end of input - The test `Stdin` can now run that real reader over a `PassThrough` (`makeStreamStdin`). Over it: - `proxy` with a held-open pipe sends the request without reading it. I checked that this test hangs when the old implicit read is put back. - `proxy -d -` reads a body that arrives after 1.5 s. - `proxy -d @-` reads stdin. - `execute` with a silent pipe fails and never calls the executor. - `execute` whose JSON arrives after the timeout fails and never runs the tool with `{}`. ## Verification I built the binary from this branch and from `origin/next` and ran both against a local mock backend: | Scenario | `origin/next` | This PR | | --- | --- | --- | | `sleep 25 \| composio proxy …/users/me/profile --toolkit gmail` | exit 0 after 25,039 ms (waited for the pipe to close) | exit 0 after 337 ms, GET sent with no body | | `{ sleep 2; echo '{"owner":"x"}'; } \| composio execute GITHUB_GET_REPOS` | ran after 2,066 ms (would wait forever on a pipe that never closes) | exit 1 after 1,279 ms with the error above; tool not run | | `sleep 25 \| composio execute GITHUB_GET_REPOS` | waits until the pipe closes | exit 1 after 1,307 ms; tool not run | | `echo '{"owner":"x"}' \| composio execute GITHUB_GET_REPOS` | runs with `{"owner":"x"}` | runs with `{"owner":"x"}` in 367 ms | | `{ sleep 2; echo '{"raw":"abc"}'; } \| composio proxy … -X POST -d -` | — | waits, then sends the body (2,054 ms) | Other checks: - `pnpm test` in `ts/packages/cli`: 230 files, 3,236 tests passed. I ran it with the `CLAUDE*` environment unset; otherwise `cli-main.test.ts` picks up the agent-host plugin tip on stderr. - `pnpm run typecheck` and `pnpm run lint:effect` are clean. CLI notes are in `ts/packages/cli/CHANGELOG.md`. There's no changeset, because `@composio/cli` is ignored by Changesets. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Rayane Boussanni [zen] <rayane@composio.dev> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: jkomyno <alberto@composio.dev>