Skip to content

fix: pass state file path instead of inlining content to avoid Linux E2BIG#4258

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/pulse-prompt-file
Mar 12, 2026
Merged

fix: pass state file path instead of inlining content to avoid Linux E2BIG#4258
marcusquinn merged 1 commit intomainfrom
bugfix/pulse-prompt-file

Conversation

@alex-solovyev
Copy link
Collaborator

@alex-solovyev alex-solovyev commented Mar 12, 2026

Summary

  • Stop inlining 135KB+ pre-fetched state into the pulse prompt argument
  • Pass a file path reference instead — agent reads the file via Read tool

Problem

On Linux, execve() enforces MAX_ARG_STRLEN = 128KB per argument. The pre-fetched state (currently 135,606 bytes) was embedded in $prompt and passed through two execve() calls:

  1. pulse-wrapper.shheadless-runtime-helper.sh --prompt "$prompt"E2BIG
  2. headless-runtime-helper.shopencode run "$prompt"also E2BIG

Every pulse invocation on Linux failed instantly with Argument list too long, producing only "Starting pulse" log entries. Backfill amplified this to ~120 failed starts per hour.

macOS has no per-argument limit (only total ARG_MAX), so this was never hit during development.

Fix

Instead of cat "$STATE_FILE" into the prompt variable, pass a reference:

/pulse

Pre-fetched state file: ~/.aidevops/logs/pulse-state.txt
Read this file before proceeding — it contains the current repo/PR/issue state
gathered by pulse-wrapper.sh BEFORE this session started.

Prompt drops from 135KB to ~200 bytes. The agent reads the file via its Read tool — one extra tool call per pulse, but:

  • Works on any state size (no 128KB ceiling)
  • Works on both Linux and macOS
  • State file was already on disk (prefetch_state() creates it)

Verification

  • bash -n: pass
  • shellcheck: clean
  • Prompt size: ~200 bytes (well under 128KB limit)
  • STATE_FILE path unchanged: ~/.aidevops/logs/pulse-state.txt

Closes #4257

Summary by CodeRabbit

  • Bug Fixes
    • Resolved argument-length limitations in state handling by optimizing how state information is communicated. The system now provides file path references instead of embedding full state content in prompts, enabling agents to access pre-fetched state information separately. This prevents potential argument-length overflow issues while maintaining complete state availability and system stability.

On Linux, execve() enforces MAX_ARG_STRLEN (128KB per argument).
The pre-fetched state (135KB+) was inlined into the prompt and
passed through two execve() calls:
  pulse-wrapper → headless-runtime-helper → opencode run
Each level hits the same 128KB limit.

Instead of inlining the state, pass a reference to the state file
(~/.aidevops/logs/pulse-state.txt). The pulse agent reads it via
its Read tool — one extra tool call, but the prompt drops from
135KB to ~200 bytes. Works on both Linux and macOS.

Closes #4257
@github-actions github-actions bot added the bug Auto-created from TODO.md tag label Mar 12, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 127ffdc1-8282-48b3-8560-13662cc1ccf3

📥 Commits

Reviewing files that changed from the base of the PR and between ad00a3a and ce2faa7.

📒 Files selected for processing (1)
  • .agents/scripts/pulse-wrapper.sh

Walkthrough

The pulse-wrapper script is refactored to avoid exceeding Linux's per-argument size limit (128KB). Instead of embedding the full pre-fetched state content inline within the prompt argument, the script now references the state file separately and documents the file path with instructions for the agent to read it independently.

Changes

Cohort / File(s) Summary
Pulse State Reference
.agents/scripts/pulse-wrapper.sh
Changed prompt construction from inlining pre-fetched state content to using a file reference. Removed cat STATE_FILE embedding; now appends a note with the STATE_FILE path when the file exists. Added explanatory comments citing MAX_ARG_STRLEN kernel limit as rationale for avoiding inlined state.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

Arguments grown too long for Linux to bear,
A state file waits in the temperate air,
No inlining bloat, just a path we refer—
E2BIG conquered, smooth operations recur! 📜

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The PR addresses the requirements from #4257 by referencing the state file instead of inlining content; however, the implementation differs from the prescribed fix by not using --prompt-file and temp file cleanup. Verify that the agent can successfully read STATE_FILE via its Read tool, confirm no temp file cleanup is needed, and validate the solution resolves E2BIG failures on Linux systems.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the core change: replacing inlined state content with a file path reference to resolve Linux E2BIG argument-length errors.
Out of Scope Changes check ✅ Passed All changes are directly scoped to resolving the E2BIG issue in pulse-wrapper.sh by modifying prompt construction; no unrelated changes detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/pulse-prompt-file
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue on Linux systems where the pulse invocation failed due to an "Argument list too long" error. Previously, the pre-fetched state was inlined directly into the prompt argument, exceeding Linux's execve() argument length limit. The solution involves refactoring the pulse-wrapper.sh script to pass a file path to the pre-fetched state instead of its content, allowing the agent to read the state from the file using its Read tool. This ensures robust operation across different operating systems and accommodates any size of pre-fetched state.

Highlights

  • Prompt Argument Handling: The method for passing pre-fetched state to the pulse prompt has been changed from inlining the state content directly into the prompt argument to providing a file path reference.
  • Linux Compatibility: This change resolves the "Argument list too long" (E2BIG) error on Linux systems, which occurred due to the execve() MAX_ARG_STRLEN limit (128KB) being exceeded by the inlined state content.
  • Agent Behavior: The agent will now use its Read tool to access the pre-fetched state from the specified file path, ensuring compatibility with varying state sizes and operating systems.
Changelog
  • .agents/scripts/pulse-wrapper.sh
    • Updated the run_pulse function to modify how the prompt is constructed, replacing the direct inclusion of state_content with a reference to $STATE_FILE.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 402 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Mar 12 22:09:47 UTC 2026: Code review monitoring started
Thu Mar 12 22:09:47 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 402

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 402
  • VULNERABILITIES: 0

Generated on: Thu Mar 12 22:09:50 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an E2BIG error on Linux by changing how the pulse state is handled. The content of the state file is no longer inlined as a command-line argument. Instead, the path to the state file is passed in the prompt, with an instruction for the agent to read the file. This change avoids the argument length limit on Linux. The code changes are confined to .agents/scripts/pulse-wrapper.sh and include comments explaining the fix.

@marcusquinn marcusquinn merged commit a94a82a into main Mar 12, 2026
28 checks passed
@marcusquinn marcusquinn deleted the bugfix/pulse-prompt-file branch March 12, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Auto-created from TODO.md tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pulse-wrapper: Argument list too long on Linux — prompt exceeds MAX_ARG_STRLEN (128KB)

2 participants