fix(grok): deliver the role blueprint as grok's system prompt via ~/.grok/AGENTS.md

The blueprint was mounted at /app/system-prompt.md but never reached grok — a real
parity gap vs the Claude path (which passes --system-prompt-file). grok agents ran
only on the per-task prompt, missing their RoboCo role/org context.

Verified live on grok 0.2.56 that the obvious flags do NOT work headless:
`--system-prompt-override` and `--rules` are silently ignored under `grok -p`
(identical output with and without). What IS honoured is grok's instruction-file
discovery — and `$HOME/.grok/AGENTS.md` is loaded GLOBALLY regardless of --cwd
(a project AGENTS.md only loads from the cwd/project root, which would pollute the
agent's git workspace). Proven end to end: a blueprint written there makes grok
adopt the role ("I am the RoboCo intake interviewer ... -- intake-1").

write_agents_md() copies /app/system-prompt.md -> ~/.grok/AGENTS.md; the one-shot
render (grok_cli_config.main) and both interactive mains call it. No git pollution
(it lives in ~/.grok, not the workspace), and it covers repo-cwd and /app-cwd
roles alike. Reverted the non-working --system-prompt-override wiring.
This commit is contained in:
Renn F
2026-06-19 05:00:58 +02:00
parent a88045aacf
commit 414b3492c4
6 changed files with 68 additions and 3 deletions
@@ -8,6 +8,8 @@ from typing import TYPE_CHECKING
from roboco.llm.providers import grok_cli_config as gc
if TYPE_CHECKING:
from pathlib import Path
import pytest
_SAMPLE_MCP = {
@@ -42,6 +44,20 @@ def test_render_config_toml_empty_when_no_servers() -> None:
assert gc.render_config_toml({"mcpServers": {}}) == ""
def test_write_agents_md_installs_the_blueprint(tmp_path: Path) -> None:
src = tmp_path / "system-prompt.md"
src.write_text("You are the RoboCo intake interviewer.", encoding="utf-8")
dest = tmp_path / ".grok" / "AGENTS.md"
assert gc.write_agents_md(source=src, dest=dest) is True
assert dest.read_text(encoding="utf-8") == "You are the RoboCo intake interviewer."
def test_write_agents_md_noops_when_source_absent(tmp_path: Path) -> None:
dest = tmp_path / ".grok" / "AGENTS.md"
assert gc.write_agents_md(source=tmp_path / "absent.md", dest=dest) is False
assert not dest.exists()
def test_developer_flags(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.delenv("ROBOCO_GROK_REASONING_EFFORT", raising=False)
args = gc.grok_cli_args("be-dev-1")