Skip to content

fix: pass prompt via stdin to avoid E2BIG error#12

Open
kevinfealey wants to merge 1 commit intoatalovesyou:mainfrom
kevinfealey:fix/e2big-stdin-prompt
Open

fix: pass prompt via stdin to avoid E2BIG error#12
kevinfealey wants to merge 1 commit intoatalovesyou:mainfrom
kevinfealey:fix/e2big-stdin-prompt

Conversation

@kevinfealey
Copy link

Problem

Large prompts (e.g., with conversation history, system prompts, or multi-modal content) can exceed the OS argument size limit (ARG_MAX, typically 128KB-2MB on Linux), causing spawn() to fail with:

Error: spawn E2BIG

Solution

Pass the prompt via stdin instead of as a CLI argument. stdin has no size limitation, making the proxy work reliably regardless of prompt size.

Changes

  • Remove prompt from CLI arguments in buildArgs()
  • Write prompt to subprocess stdin before closing it
  • Update comments to document the approach

Large prompts (e.g., with conversation history) can exceed the OS
argument size limit (ARG_MAX), causing spawn() to fail with E2BIG.

This change passes the prompt via stdin instead of as a CLI argument,
which has no size limitation.
@kevinfealey kevinfealey force-pushed the fix/e2big-stdin-prompt branch from 8a31261 to d5f9bfa Compare February 9, 2026 06:24
smartchainark pushed a commit to smartchainark/claude-max-api-proxy that referenced this pull request Feb 10, 2026
Large prompts (conversation history + system prompt) can exceed the OS
argument size limit, causing spawn() to fail with E2BIG. Passing via
stdin has no size limitation.

Credit: PR atalovesyou#12 by @kevinfealey

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bwiedmann added a commit to bwiedmann/claude-max-api-proxy that referenced this pull request Feb 15, 2026
… E2BIG error

# Conflicts:
#	src/subprocess/manager.ts
wende added a commit to wende/claude-max-api-proxy that referenced this pull request Feb 18, 2026
Triaged all 14 open PRs from atalovesyou/claude-max-api-proxy,
implemented the valuable fixes, and added end-to-end test coverage.

Changes:
- Fix normalizeModelName crash on undefined model (atalovesyou#7 regression)
- Pass prompt via stdin instead of CLI arg to avoid E2BIG (atalovesyou#12)
- Increase subprocess timeout from 5 to 15 minutes (atalovesyou#20)
- Add Claude 4.5/4.6 model IDs and claude-max/ prefix (atalovesyou#10, atalovesyou#20)
- Include usage data in final streaming SSE chunk (atalovesyou#16)
- Wrap subprocess logging with DEBUG_SUBPROCESS env check (atalovesyou#5, atalovesyou#16)
- Strip CLAUDECODE env var from subprocesses (own fix)
- Add e2e test suite (7 tests covering health, models, completions)
wende added a commit to wende/claude-max-api-proxy that referenced this pull request Feb 18, 2026
Triaged all 14 open PRs from atalovesyou/claude-max-api-proxy,
implemented the valuable fixes, and added end-to-end test coverage.

Changes:
- Fix normalizeModelName crash on undefined model (atalovesyou#7 regression)
- Pass prompt via stdin instead of CLI arg to avoid E2BIG (atalovesyou#12)
- Increase subprocess timeout from 5 to 15 minutes (atalovesyou#20)
- Add Claude 4.5/4.6 model IDs and claude-max/ prefix (atalovesyou#10, atalovesyou#20)
- Include usage data in final streaming SSE chunk (atalovesyou#16)
- Wrap subprocess logging with DEBUG_SUBPROCESS env check (atalovesyou#5, atalovesyou#16)
- Strip CLAUDECODE env var from subprocesses (own fix)
- Add e2e test suite (7 tests covering health, models, completions)

Co-Authored-By: kevinfealey <10552286+kevinfealey@users.noreply.github.com>
Co-Authored-By: Max <257223904+Max-shipper@users.noreply.github.com>
Co-Authored-By: James Hansen <1359077+jamshehan@users.noreply.github.com>
Co-Authored-By: bitking <213560776+smartchainark@users.noreply.github.com>
Co-Authored-By: Alex Rudloff's AI Agents <258647843+alexrudloffBot@users.noreply.github.com>
Grivn added a commit to mnemon-dev/claude-max-api-proxy that referenced this pull request Feb 20, 2026
Fixes applied (from upstream PRs atalovesyou#7, atalovesyou#11, atalovesyou#12, atalovesyou#13, atalovesyou#17, atalovesyou#20):

- fix: normalizeModelName crash on undefined model (issue atalovesyou#21)
- fix: [object Object] serialization for array content parts
- fix: E2BIG error by passing prompt via stdin instead of CLI arg
- fix: ensureString on result.result to prevent non-string output
- feat: CLAUDE_DANGEROUSLY_SKIP_PERMISSIONS env var for headless mode
- feat: OPENCLAW_PROXY=1 env injection for hook isolation
- feat: model aliases for claude-*-4-5, claude-*-4-6 generations
- feat: claude-proxy/ provider prefix support
- feat: developer role support in message conversion
- perf: increase subprocess timeout from 5min to 15min

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
chrisle added a commit to chrisle/claude-max-api-proxy that referenced this pull request Feb 27, 2026
Users can now send large prompts without E2BIG errors, use array-based
content format for multimodal support, properly handle system prompts,
and receive token usage data in streaming responses. Model names with
any provider prefix are now correctly normalized.

Changes:
- Fix array content serialization preventing [object Object] bugs
- Pass prompts via stdin to prevent E2BIG errors with large requests
- Add proper system prompt support via --append-system-prompt flag
- Include usage data in final streaming chunks
- Support any provider prefix in model names (claude-max/, etc.)
- Add CLAUDE_DANGEROUSLY_SKIP_PERMISSIONS env var for service mode
- Update to Claude 4.5/4.6 model support

Incorporates improvements from PRs atalovesyou#12, atalovesyou#13, atalovesyou#16, atalovesyou#24, atalovesyou#27 at
https://github.com/atalovesyou/claude-max-api-proxy
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.

1 participant