Grok Build runtime spawns bare `grok` (TUI) instead of `grok agent --always-approve stdio` — agents fail with ENXIO
- Dominant language
- Rust
- Stars
- 32.7k
- Forks
- 4.3k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 253
Description
## Summary
Selecting **Grok Build** as the managed-agent runtime starts Fizz/Honey/Bumble with:
```text
agent_cmd=/Users/.../grok
```
and **empty `agent_args`**. That launches the interactive TUI, not the ACP server. Under Buzz (no controlling TTY) every pool worker exits immediately:
```text
Error: Device not configured (os error 6)
ERROR buzz_acp: agent initialize failed: Agent process exited unexpectedly
Error: all 10 agents failed to start — cannot continue
```
Claude / other ACP-native adapters work on the same machine. The Grok CLI is installed and authenticated; this is a harness arg wiring bug, not auth.
## Environment
- **Buzz**: 0.5.0 (macOS, desktop)
- **Grok CLI**: 0.2.114 (`~/.local/bin/grok` → `~/.grok/bin/grok`)
- **OS**: macOS arm64
- **Config**: `preferred_runtime: "grok"` in `global-agent-config.json`
- Managed agents end up with:
```json
"agent_command": "claude-agent-acp",
"agent_command_override": "grok",
"agent_args": []
```
## Steps to reproduce
1. Install Grok CLI (`grok` on PATH / `~/.grok/bin`) and `grok login` (or set `XAI_API_KEY`).
2. Install latest Buzz desktop; create/start Welcome Team agents (Fizz etc.).
3. Set agent runtime / preferred runtime to **Grok Build**.
4. Start agents and open the harness log.
## Expected
Spawn should match the preset harness definition on `main`:
```rust
// desktop/src-tauri/src/managed_agents/discovery.rs — PRESET_HARNESSES
PresetHarness {
id: "grok",
label: "Grok Build",
command: "grok",
args: &["agent", "--always-approve", "stdio"],
...
}
```
i.e. effectively:
```bash
grok agent --always-approve stdio
```
ACP `initialize` should succeed (same as a manual pipe of JSON-RPC over stdio).
## Actual
- Log line: `agent_cmd=.../grok` with no `agent stdio` args.
- Child prints `Error: Device not configured (os error 6)` (ENXIO) and exits.
- All parallel workers fail; harness exits status 1: `all 10 agents failed to start`.
Manual repro of the bad spawn:
```bash
# bare TUI, no TTY — same ENXIO Buzz sees
/Users/$USER/.local/bin/grok Some(vec![
"agent".into(),
"--always-approve".into(),
"stdio".into(),
]),
"omp" | "opencode" | "kimi" | "cursor" | "cursor-agent" => Some(vec!["acp".into()]),
// ...
```
Prefer a single source of truth: derive defaults from `PRESET_HARNESSES` rather than a second match table.
2. **When applying `preferred_runtime` / command override from a preset**, also persist (or resolve at spawn) that preset's `args`, not only the command.
3. **Regression test**: spawn path / `normalize_agent_args("grok", vec![])` must yield `["agent", "--always-approve", "stdio"]`; integration smoke that `BUZZ_ACP_AGENT_COMMAND=grok` with empty args can complete ACP `initialize` without a TTY.
## Workaround (works today)
Edit managed agents so args are set explicitly, then restart agents:
```json
"agent_command_override": "/Users//.local/bin/grok",
"agent_args": ["agent", "stdio"]
```
or point the override at a tiny wrapper:
```bash
#!/bin/bash
exec "$HOME/.local/bin/grok" agent stdio "$@"
```
(`--always-approve` is recommended for managed agents so Grok-side tool prompts do not deadlock headless ACP; Buzz already documents this in the Grok preset PRs.)
## Related
- Closed feature: #2347 (register Grok Build as first-class ACP runtime)
- Closed PRs that defined the intended args: #2812, #2918, #2546 (`agent --always-approve stdio`)
- Related enhancement (not this bug): #3279 “Add Grok CLI option”
- Note: some earlier Grok PR discussion mentioned `/dev/tty` / spawn-context issues on the CLI side; current Grok `agent stdio` completes `initialize` fine over pipes — the Buzz-side empty-args spawn is sufficient to explain this failure.
## Acceptance criteria
- [ ] Selecting **Grok Build** as preferred/agent runtime starts agents without ENXIO
- [ ] Harness log shows ACP init for Grok (`agentInfo` / capabilities), not TUI ENXIO
- [ ] Empty `agent_args` + command `grok` normalizes to `agent --always-approve stdio` (or equivalent from preset)
- [ ] Unit coverage for `normalize_agent_args("grok", [])`
Contributor guide
Assessment
This issue has not been assessed yet.