[GH-ISSUE #3474] Grok CLI provider: every request pays ~10s of repo indexing when Marinara runs from a git checkout #1877

Closed
opened 2026-10-21 05:43:27 +07:00 by bsakaguchi · 1 comment
Owner

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

Problem

The Grok CLI provider spawns grok with its working directory set to DATA_DIR/grok-cli. The grok CLI walks up from its cwd to the nearest .git, and indexes the entire working tree of that repository at startup of every one-shot call.

When Marinara runs from a git checkout (source installs, contributors, self-hosters), DATA_DIR/grok-cli sits inside the Marinara repo — so every chat generation and every agent/tracker request re-indexes the whole checkout before the API call even starts.

Docker and installer deployments have no .git above the data dir, which is why this is easy to miss.

Measurements

Identical one-line prompt (Say OK and nothing else.), grok 0.2.14, Linux:

cwd wall time user CPU
empty dir outside any repo 4.7 s 1.0 s
data/grok-cli (empty, inside the Marinara checkout) 15.6 s 5.3 s

An strace of the slow case shows 45,000+ file opens (all of packages/client, packages/server, docs, android…) before the CLI contacts the API.

End-to-end through Marinara's POST /api/connections/:id/test (a real Reply with OK. request): 12.1 s before the fix, 5.4 s after.

No CLI flag disables the discovery (--verbatim does not; a stub empty .git directory is not accepted as a repo boundary — verified).

Fix

Move the scratch cwd from DATA_DIR/grok-cli to the OS temp dir (os.tmpdir()), which is never inside a git checkout. A uid suffix keeps per-user paths distinct on shared hosts. Prompt files already live outside the cwd, so nothing else changes.

As a side benefit, the CLI's workspace discovery can no longer see anything under DATA_DIR at all, which strengthens the existing "keep prompt transcripts outside --cwd" isolation from #3464.

PR incoming (owner: @myaiexp, agent-assisted).

🤖 Generated with Claude Code

Originally created by @myaiexp on GitHub (Jul 11, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3474 ## Problem The Grok CLI provider spawns `grok` with its working directory set to `DATA_DIR/grok-cli`. The grok CLI walks up from its cwd to the nearest `.git`, and indexes the **entire working tree** of that repository at startup of every one-shot call. When Marinara runs from a git checkout (source installs, contributors, self-hosters), `DATA_DIR/grok-cli` sits inside the Marinara repo — so **every chat generation and every agent/tracker request** re-indexes the whole checkout before the API call even starts. Docker and installer deployments have no `.git` above the data dir, which is why this is easy to miss. ## Measurements Identical one-line prompt (`Say OK and nothing else.`), grok 0.2.14, Linux: | cwd | wall time | user CPU | | --- | --- | --- | | empty dir outside any repo | 4.7 s | 1.0 s | | `data/grok-cli` (empty, inside the Marinara checkout) | 15.6 s | 5.3 s | An `strace` of the slow case shows **45,000+ file opens** (all of `packages/client`, `packages/server`, docs, android…) before the CLI contacts the API. End-to-end through Marinara's `POST /api/connections/:id/test` (a real `Reply with OK.` request): **12.1 s before the fix, 5.4 s after**. No CLI flag disables the discovery (`--verbatim` does not; a stub empty `.git` directory is not accepted as a repo boundary — verified). ## Fix Move the scratch cwd from `DATA_DIR/grok-cli` to the OS temp dir (`os.tmpdir()`), which is never inside a git checkout. A uid suffix keeps per-user paths distinct on shared hosts. Prompt files already live outside the cwd, so nothing else changes. As a side benefit, the CLI's workspace discovery can no longer see anything under `DATA_DIR` at all, which strengthens the existing "keep prompt transcripts outside `--cwd`" isolation from #3464. PR incoming (owner: @myaiexp, agent-assisted). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
bsakaguchi 2026-10-21 05:43:27 +07:00
  • closed this issue
  • added the
    in-pr
    label
Author
Owner

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

Thank you for the PR!

<!-- gh-comment-id:4946982741 --> @SpicyMarinara commented on GitHub (Jul 11, 2026): Thank you for the PR!
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#1877
No description provided.