Add native grok agent backend#276
Open
falkoro wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for the Grok agent across configuration, detection, and execution, including a new agent implementation, fakeagent support, and unit tests.
Changes:
- Introduces
AgentGrokand wires it into agent construction and defaults. - Adds Grok CLI argument reservation/validation and includes Grok in
doctorchecks. - Implements
grokAgentplus fakeagent Grok support and tests for prompt/arg building.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/types/types.go | Adds AgentGrok constant for agent enumeration. |
| internal/config/config.go | Registers Grok binary defaults, reserved args, and validation messaging. |
| internal/cli/doctor.go | Adds Grok to binary presence checks. |
| internal/agent/agent.go | Enables NewWithOptions creation for Grok and updates error message. |
| internal/agent/grok.go | Implements Grok agent execution, prompt/args building, and retries. |
| internal/agent/grok_test.go | Adds unit tests for Grok agent construction and helpers. |
| cmd/fakeagent/main.go | Routes fakeagent grok invocations. |
| cmd/fakeagent/grok.go | Implements fake Grok CLI behavior for e2e scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
One-shot CLI backend for the standalone grok CLI (Grok Build), modeled on the claude/codex/pi pattern: prompt via temp file (--prompt-file), plain text output, schema contract inlined in the prompt (like pi), gitSafeEnv, classifyTransient retries, context cancellation during streaming. - internal/agent/grok.go + grok_test.go - types: AgentGrok; agent.go: factory case + error message - config: agent_args_override allowlist + reserved flags (incl. --effort, which the grok API rejects and must never be injected) - cmd/fakeagent: grok handler for the e2e harness Verified: gofmt, make lint, go test -race ./... (one pre-existing TestInitTracksCommandTelemetry failure also fails on clean upstream), make e2e green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- stream grok stdout with a bufio.Reader (incremental ReadString) instead of a bufio.Scanner with a 256MB max-token buffer, avoiding a large up-front allocation / OOM risk on a single very long line - correct buildGrokArgs comment: managed flags are appended last and therefore take precedence (and are reserved in config); the prior comment claimed the opposite - drop developer-specific /home/falk/.grok/bin/grok paths from grok_test.go in favour of a neutral /path/to/grok Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
|
Rebased onto
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
agent: grok— a native one-shot CLI backend for the standalone grok CLI (Grok Build), modeled on the existing claude/codex/pi pattern:internal/agent/grok.go: temp-file prompt (--prompt-file) so large review prompts never hit argv limits, plain-text output via--output-format plain, schema contract inlined in the prompt (same approach as pi),gitSafeEnv,classifyTransientretries, context cancellation during streaming.internal/types:AgentGrok; factory case inNewWithOptions; doctor listing.internal/config:agent_args_overrideallowlist entry + reserved flags — including--effort, which the grok API rejects (400) and must never be injected.cmd/fakeagent: grok handler for the e2e harness.--effort.Why
grok is a capable, cheap reviewer/writer; today the only way to route it through no-mistakes is via opencode with an xAI model, which adds a server dependency and breaks in two known ways (
opencode serverejects--modelfromagent_args_override, and xAI's 200-tool cap kills startup when global MCP servers are configured). A native backend removes that chain entirely.Verification
gofmtclean,make lintcleango test -race ./...— green exceptTestInitTracksCommandTelemetry, which also fails on a clean checkout of main in my environment (network-dependent)make e2egreen (131s)agent: grok+agent_path_override) reviewing a 108-file Astro monorepo diff.🤖 Generated with Claude Code