[PR #3464] [MERGED] Deliver Grok CLI prompts via --prompt-file and lift the 32k context clamp #5951

Closed
opened 2026-10-23 04:05:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3464
Author: @myaiexp
Created: 7/11/2026
Status: ✅ Merged
Merged: 7/11/2026
Merged by: @SpicyMarinara

Base: staging ← Head: grok-cli-prompt-file


📝 Commits (4)

  • 8de8e5a Deliver Grok CLI prompts via --prompt-file and lift the 32k context clamp
  • 8a053de Keep the 32k default window; honor explicitly configured max context
  • 61399ec Isolate Grok CLI prompt files
  • 93da6d7 Merge remote-tracking branch 'origin/staging' into grok-cli-prompt-file

📊 Changes

3 files changed (+38 additions, -11 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/components/connections/ConnectionEditor.tsx (+1 -1)
📝 packages/server/src/services/llm/providers/grok-subscription.provider.ts (+36 -10)

📄 Description

Linked issue

Closes #3463

Why this change

  • The Grok CLI subscription provider delivers the whole flattened transcript as one inline -p argument. A single exec argument is capped by the OS (128 KiB on Linux via MAX_ARG_STRLEN, ~32 KiB command lines on Windows), so long transcripts kill the spawn with E2BIG before any request is made.
  • The 32k context clamp doesn't prevent this: it counts characters (4 chars/token estimate) while the OS counts bytes, so multibyte-heavy chats (CJK, emoji-dense) can crash under the clamp.
  • Separately, the clamp silently ignored a deliberately configured Max Context Window — while the connection editor promises "larger saved values are kept in settings".

What changed

  • The prompt is written to a unique temp file in the existing grok scratch dir (DATA_DIR/grok-cli) and passed via --prompt-file; the file is removed when the CLI exits (finally). Unique filenames keep parallel agent/chat requests safe.
  • The 32k default window is kept — it also serves as the turn-limit guardrail described in the connection editor, and connections that never touched the setting behave exactly as before. What's removed is only the silent cap on explicitly configured values: a user who deliberately sets a larger Max Context Window now gets it, and an oversized value fails soft through the existing "max turns reached" guidance (which already tells users to lower the setting) instead of being silently overridden.
  • Connection editor copy updated to describe the new behavior; CHANGELOG entry under [Unreleased] → Fixed.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Unticked boxes, honestly: I run Marinara bare-metal (no container), and the only UI change is one help-text string in the connection editor, which I have not click-tested in a browser. What I did verify, on Linux with grok CLI 0.2.14:

  • Reproduced the failure: a 157 KB prompt passed inline via -p fails to spawn with "Argument list too long" (E2BIG) — the kernel rejects the exec before any API call.
  • Ran the same 157 KB prompt through --prompt-file using the provider's exact flag set (--no-auto-update --output-format plain --system-prompt-override … --no-plan --no-subagents --no-memory --disable-web-search --disallowed-tools run_terminal_command --max-turns 8 --cwd <scratch>); the CLI returned the expected completion.
  • The patched build has been running on my own instance since 2026-07-11, and the Grok CLI subscription connection is in regular chat use.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Text-only change to the Max Context Window help text in the connection editor (no layout or behavior change).

Summary by CodeRabbit

  • Bug Fixes

    • Fixed Grok CLI failures when processing long or multibyte-heavy conversations by delivering prompts through temporary files.
    • Grok CLI now honors explicitly configured Max Context Window values instead of silently limiting them to 32k.
  • Documentation

    • Updated Max Context Window guidance for Grok subscriptions, including safer starting recommendations and advice to adjust values gradually based on reliability.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/3464 **Author:** [@myaiexp](https://github.com/myaiexp) **Created:** 7/11/2026 **Status:** ✅ Merged **Merged:** 7/11/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `grok-cli-prompt-file` --- ### 📝 Commits (4) - [`8de8e5a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8de8e5a052bfc72c860dc48209d86166831d30ff) Deliver Grok CLI prompts via --prompt-file and lift the 32k context clamp - [`8a053de`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8a053de463df41ac0d17f54dbc992a482a20c3ac) Keep the 32k default window; honor explicitly configured max context - [`61399ec`](https://github.com/Pasta-Devs/Marinara-Engine/commit/61399ec3d6d886e38f0c1f9acccafcdfa529b5b6) Isolate Grok CLI prompt files - [`93da6d7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/93da6d765c54acaa2b0642848924e2265a82464c) Merge remote-tracking branch 'origin/staging' into grok-cli-prompt-file ### 📊 Changes **3 files changed** (+38 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+1 -1) 📝 `packages/server/src/services/llm/providers/grok-subscription.provider.ts` (+36 -10) </details> ### 📄 Description ## Linked issue Closes #3463 ## Why this change - The Grok CLI subscription provider delivers the whole flattened transcript as one inline `-p` argument. A single exec argument is capped by the OS (128 KiB on Linux via `MAX_ARG_STRLEN`, ~32 KiB command lines on Windows), so long transcripts kill the spawn with `E2BIG` before any request is made. - The 32k context clamp doesn't prevent this: it counts characters (4 chars/token estimate) while the OS counts bytes, so multibyte-heavy chats (CJK, emoji-dense) can crash *under* the clamp. - Separately, the clamp silently ignored a deliberately configured Max Context Window — while the connection editor promises "larger saved values are kept in settings". ## What changed - The prompt is written to a unique temp file in the existing grok scratch dir (`DATA_DIR/grok-cli`) and passed via `--prompt-file`; the file is removed when the CLI exits (`finally`). Unique filenames keep parallel agent/chat requests safe. - The **32k default window is kept** — it also serves as the turn-limit guardrail described in the connection editor, and connections that never touched the setting behave exactly as before. What's removed is only the silent cap on *explicitly configured* values: a user who deliberately sets a larger Max Context Window now gets it, and an oversized value fails soft through the existing "max turns reached" guidance (which already tells users to lower the setting) instead of being silently overridden. - Connection editor copy updated to describe the new behavior; CHANGELOG entry under `[Unreleased]` → `Fixed`. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Unticked boxes, honestly: I run Marinara bare-metal (no container), and the only UI change is one help-text string in the connection editor, which I have not click-tested in a browser. What I did verify, on Linux with grok CLI 0.2.14: - Reproduced the failure: a 157 KB prompt passed inline via `-p` fails to spawn with "Argument list too long" (`E2BIG`) — the kernel rejects the exec before any API call. - Ran the same 157 KB prompt through `--prompt-file` using the provider's exact flag set (`--no-auto-update --output-format plain --system-prompt-override … --no-plan --no-subagents --no-memory --disable-web-search --disallowed-tools run_terminal_command --max-turns 8 --cwd <scratch>`); the CLI returned the expected completion. - The patched build has been running on my own instance since 2026-07-11, and the Grok CLI subscription connection is in regular chat use. ## Docs and release impact - [ ] No docs changes needed - [x] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Text-only change to the Max Context Window help text in the connection editor (no layout or behavior change). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Fixed Grok CLI failures when processing long or multibyte-heavy conversations by delivering prompts through temporary files. - Grok CLI now honors explicitly configured Max Context Window values instead of silently limiting them to 32k. - **Documentation** - Updated Max Context Window guidance for Grok subscriptions, including safer starting recommendations and advice to adjust values gradually based on reliability. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:05:32 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5951
No description provided.