Skip to content

[FEATURE]: Native --stdin support for opencode run to handle large prompts without ARG_MAX errors #25508

Closed as not planned

Description

@aleka

Problem Description

When using opencode run with large prompts (e.g., code reviews of 1700+ line files), the prompt is passed as a positional argument. This causes critical issues:

  1. ARG_MAX limit: On Linux, the maximum argument length is ~2MB. Large prompts exceed this, causing E2BIG: argument list too long errors before the command even executes.
  2. Performance: Passing large strings as command-line arguments is inefficient and slow.
  3. Workaround complexity: Currently requires writing to a temp file and using -f flag, which has security restrictions (files must be within project directory, see related issues).

Current Behavior

# This fails with large prompts (>2MB)
opencode run --model kimi-for-coding/kimi-k2-thinking "very large prompt..."

# Current workaround: write to file in project directory
echo "$prompt" > ./temp_prompt.txt
opencode run --model kimi-for-coding/kimi-k2-thinking "Review this" -f ./temp_prompt.txt

Proposed Solution

Add native --stdin support for opencode run:

# Option 1: Explicit --stdin flag
printf '%s' "$prompt" | opencode run --model kimi-for-coding/kimi-k2-thinking --stdin

# Option 2: Auto-detect stdin when no positional args
printf '%s' "$prompt" | opencode run --model kimi-for-coding/kimi-k2-thinking

Benefits

  • No ARG_MAX issues: Stdin has no practical size limit
  • Better performance: No command-line parsing of large strings
  • Simpler integration: Tools can pipe content directly without temp files
  • Security: No need to create temp files in project directory

Related Issues

Context

This issue was discovered while working with GGA, a tool that uses OpenCode for automated code reviews. When reviewing commits with large files, the prompt exceeds ARG_MAX limits, causing timeouts and failures.

Environment

  • OpenCode version: 1.14.33
  • OS: Linux (Ubuntu/Debian)
  • Shell: Bash 5.x
  • Use case: Automated code review via CI/CD pipelines

Verification

Activity

  1. github-actions commented on May 3, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The title should start with [FEATURE]: (e.g., [FEATURE]: Native --stdin support for opencode run...)
    • The Feature Request template requires a verification checkbox confirming the feature hasn't been suggested before — this is missing from the issue body

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. changed the title [-]Feature Request: Native --stdin support for opencode run to handle large prompts without ARG_MAX errors[/-] [+][FEATURE]: Native --stdin support for opencode run to handle large prompts without ARG_MAX errors[/+] on May 3, 2026
  3. github-actions commented on May 3, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! Everything looks good now — the feature request is clear, includes real context, system info, and proper verification. We appreciate you taking the time to fix it up.

  4. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions