-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: prevent E2BIG errors and mixed system prompts in Claude Code provider #8120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -154,15 +154,9 @@ function runProcess({ | |||||||
maxOutputTokens, | ||||||||
}: ClaudeCodeOptions & { maxOutputTokens?: number }) { | ||||||||
const claudePath = path || "claude" | ||||||||
const isWindows = os.platform() === "win32" | ||||||||
|
||||||||
// Build args based on platform | ||||||||
const args = ["-p"] | ||||||||
|
||||||||
// Pass system prompt as flag on non-Windows, via stdin on Windows (avoids cmd length limits) | ||||||||
if (!isWindows) { | ||||||||
args.push("--system-prompt", systemPrompt) | ||||||||
} | ||||||||
// Build args - always pass system prompt as flag to avoid mixing with Claude Code's default | ||||||||
const args = ["-p", "--system-prompt", systemPrompt] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we expand this comment to be more explicit about the dual purpose? Something like:
Suggested change
|
||||||||
|
||||||||
args.push( | ||||||||
"--verbose", | ||||||||
|
@@ -196,17 +190,9 @@ function runProcess({ | |||||||
timeout: CLAUDE_CODE_TIMEOUT, | ||||||||
}) | ||||||||
|
||||||||
// Prepare stdin data: Windows gets both system prompt & messages (avoids 8191 char limit), | ||||||||
// other platforms get messages only (avoids Linux E2BIG error from ~128KiB execve limit) | ||||||||
let stdinData: string | ||||||||
if (isWindows) { | ||||||||
stdinData = JSON.stringify({ | ||||||||
systemPrompt, | ||||||||
messages, | ||||||||
}) | ||||||||
} else { | ||||||||
stdinData = JSON.stringify(messages) | ||||||||
} | ||||||||
// Prepare stdin data: only send messages to avoid E2BIG errors | ||||||||
// System prompt is now always passed via --system-prompt flag | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great simplification! These comments clearly explain the rationale. Is the |
||||||||
const stdinData = JSON.stringify(messages) | ||||||||
|
||||||||
// Use setImmediate to ensure process is spawned before writing (prevents stdin race conditions) | ||||||||
setImmediate(() => { | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good update to the test name! This now accurately reflects that we're testing consistent behavior across all platforms rather than platform-specific behavior.