Skip to content

fix(agent): pass acpx prompt via temp file to avoid Windows CLI length limit#334

Open
sridhar-3009 wants to merge 1 commit into
kunchenguid:mainfrom
sridhar-3009:fix/acpx-prompt-file-315
Open

fix(agent): pass acpx prompt via temp file to avoid Windows CLI length limit#334
sridhar-3009 wants to merge 1 commit into
kunchenguid:mainfrom
sridhar-3009:fix/acpx-prompt-file-315

Conversation

@sridhar-3009

Copy link
Copy Markdown

Summary

Fixes #315.

Root cause

acpxAgent.buildArgs appended the full prompt as a positional CLI argument:

acpx [flags] gemini exec <prompt-text>

On Windows, CreateProcess caps the entire command line at 8191 characters. Large prompts (diff + JSON schema + workspace preamble) are silently truncated at that boundary. The truncated text ends mid-sentence, so acpx responds in plain prose ("Your message looks cut off...") and no-mistakes fails to parse the expected JSON object:

acp:cursor output parse: invalid character 'Y' looking for beginning of value

Short prompts work; large ones (review, document) do not.

Fix

Write the prompt to a named temp file before starting the subprocess, then invoke:

acpx [flags] gemini exec -f <tempfile>

acpx has supported exec -f <file> since at least v0.11.0 (the version in the bug report). The temp file is removed via defer os.Remove after cmd.Wait() returns.

This change is platform-agnostic: no prompt size can exceed OS limits via args any more.

Tests

  • Updated TestACPAgentBuildArgsUsesExecMode to assert trailing args are [..., "exec", "-f", "<path>"]
  • Updated TestACPAgentRunParsesAcpxJSONOutput shell script to log prompt file content so the assertion can still verify the prompt text reaches acpx
  • Full go test ./internal/agent/... passes

Test plan

  • go test ./internal/agent/... -run TestACPAgent — all pass
  • go test ./internal/agent/... — full suite passes

…h limit

acpx exec accepted the full prompt as a positional CLI argument.  On
Windows, CreateProcess caps the command line at 8191 characters; large
prompts (diff + JSON schema + workspace preamble) are silently truncated
at that boundary.  The truncated text ends mid-sentence, acpx replies in
prose, and no-mistakes fails to parse the expected JSON output.

Fix: write the prompt to a temp file before starting the process and
invoke "acpx exec -f <file>" instead.  acpx has supported the -f flag
on exec since at least v0.11.0 (the version reported in issue kunchenguid#315).
The file is removed via defer after cmd.Wait() returns.

This change is safe on all platforms: there is no prompt-size path left
that could exceed OS limits.

Fixes kunchenguid#315.
@kunchenguid

Copy link
Copy Markdown
Owner

Thanks for the contribution, @sridhar-3009! One process note on this repo: PRs need to be raised through no-mistakes (git push no-mistakes), which runs the review/test/lint/CI pipeline and stamps the required signature into the PR body. This PR is currently failing the "PR must be raised via no-mistakes" check because it wasn't raised that way.

If working from a fork was the blocker, that's fixed as of v1.30.0 (#306). Per CONTRIBUTING.md: point origin at this parent repo, run no-mistakes init --fork-url <your-fork-url>, then git push no-mistakes.

I won't be merging PRs that bypass the gate going forward, but I'd genuinely love to land your work once it's re-raised. Thanks for understanding! 🙏

@kunchenguid

Copy link
Copy Markdown
Owner

Thanks for the contribution! One process note: this repo only merges changes that come through the no-mistakes pipeline, so the required PR must be raised via no-mistakes check is red here because the PR was opened directly.

Could you re-raise it via no-mistakes? Running the pipeline on your branch (review → test → lint → docs → push) opens/updates the PR through the gate and turns that check green, making it eligible to merge. The change itself looks useful - it just needs to come through the pipeline to stay consistent with the rest of the queue.

You have several open in this area, so the same applies to each. Happy to help if the gate setup gives you any trouble.

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.

acp:* agent steps fail on Windows when prompt exceeds CLI length (truncates at Workspace boundary)

2 participants