[GH-ISSUE #3463] Grok CLI subscription: E2BIG on long transcripts; context hard-capped at 32k #1871

Closed
opened 2026-10-21 05:43:24 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @myaiexp on GitHub (Jul 11, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3463

Originally assigned to: @SpicyMarinara on GitHub.

What happens

The Grok CLI subscription provider passes the entire flattened transcript to the CLI as one inline -p argument (grok-subscription.provider.ts). Operating systems cap the size of a single exec argument — 128 KiB on Linux (MAX_ARG_STRLEN), roughly 32 KiB for the whole command line on Windows — so once a chat's transcript outgrows that, the spawn itself fails (E2BIG / "Argument list too long") before any request is made.

The provider's 32k context ceiling (GROK_CLI_DEFAULT_CONTEXT_TOKENS, enforced in normalizeGrokCliContextWindow) tracks that argv ceiling almost exactly (32k tokens × the 4-chars-per-token estimate = 128,000 chars), but it counts characters while the OS counts bytes — so multibyte-heavy chats (CJK, emoji-dense roleplay) can still blow the limit under the clamp. It also caps subscription users at 32k context even when their configured model supports far more.

Reproduction

Linux, grok CLI 0.2.14. Any chat whose flattened prompt exceeds 131,072 bytes: the request fails at spawn. Verified directly: a 157 KB prompt fails with the provider's inline -p shape and completes when delivered via --prompt-file with the otherwise identical flag set.

Suggested fix

The grok CLI accepts --prompt-file <PATH>. Writing the prompt to a temp file in the existing grok scratch dir and passing the path removes the argv limit entirely — and with it, the reason for the 32k clamp. PR to follow.

Originally created by @myaiexp on GitHub (Jul 11, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3463 Originally assigned to: @SpicyMarinara on GitHub. ### What happens The Grok CLI subscription provider passes the entire flattened transcript to the CLI as one inline `-p` argument (`grok-subscription.provider.ts`). Operating systems cap the size of a single exec argument — 128 KiB on Linux (`MAX_ARG_STRLEN`), roughly 32 KiB for the whole command line on Windows — so once a chat's transcript outgrows that, the spawn itself fails (`E2BIG` / "Argument list too long") before any request is made. The provider's 32k context ceiling (`GROK_CLI_DEFAULT_CONTEXT_TOKENS`, enforced in `normalizeGrokCliContextWindow`) tracks that argv ceiling almost exactly (32k tokens × the 4-chars-per-token estimate = 128,000 chars), but it counts **characters** while the OS counts **bytes** — so multibyte-heavy chats (CJK, emoji-dense roleplay) can still blow the limit *under* the clamp. It also caps subscription users at 32k context even when their configured model supports far more. ### Reproduction Linux, grok CLI 0.2.14. Any chat whose flattened prompt exceeds 131,072 bytes: the request fails at spawn. Verified directly: a 157 KB prompt fails with the provider's inline `-p` shape and completes when delivered via `--prompt-file` with the otherwise identical flag set. ### Suggested fix The grok CLI accepts `--prompt-file <PATH>`. Writing the prompt to a temp file in the existing grok scratch dir and passing the path removes the argv limit entirely — and with it, the reason for the 32k clamp. PR to follow.
bsakaguchi 2026-10-21 05:43:24 +07:00
  • closed this issue
  • added the
    in-pr
    label
Author
Owner

@SpicyMarinara commented on GitHub (Jul 11, 2026):

Thank you for tackling it! Remind me if you already have a Contributor role on my Discord?

<!-- gh-comment-id:4944341931 --> @SpicyMarinara commented on GitHub (Jul 11, 2026): Thank you for tackling it! Remind me if you already have a Contributor role on my Discord?
Author
Owner

@myaiexp commented on GitHub (Jul 11, 2026):

Just joined, sent a message in general

<!-- gh-comment-id:4944673464 --> @myaiexp commented on GitHub (Jul 11, 2026): Just joined, sent a message in general
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#1871
No description provided.