graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
feat(evals): run Pi on SuperGrok the same way as graff-dev
Cursor Agent4025b5994bb7
diff --git a/graff-evals/README.md b/graff-evals/README.mdindex e6538af6..dcc96a12 100644--- a/graff-evals/README.md+++ b/graff-evals/README.md@@ -25,6 +25,8 @@ harness under test spends model calls.```sh./run.py --suite swe --harness graff-dev-old,graff-dev --model grok-4.6 -j 12./run.py --suite core,rlm,swe --harness graff-dev-old,graff-dev -j 8+# Pi on the same SuperGrok seat (`npm i -g @earendil-works/pi-coding-agent`):+./run.py --suite swe --harness graff-dev,pi-xai --model grok-4.6 -j 6```## Run it@@ -59,10 +61,13 @@ the last run for post-mortems; both are disposable.`harnesses.json` declares each harness as a command template plus parsers:-- `answer` — where the final answer text comes from (`stdout`, or- `grok-stream` for grok's `streaming-messages-json` result event).+- `answer` — where the final answer text comes from (`stdout`,+ `grok-stream` for grok's `streaming-messages-json` result event, or+ `pi-json` for Pi's `--mode json` `message_end` text).- `usage` — how to extract token counts (`graff-stderr` parses graff's- `[usage]` line; `grok-stream` reads the result event's usage).+ `[usage]` line; `grok-stream` / `pi-json` read the harness event).+ Pi `first_out_s` is the first JSONL line (`session`), not TUI first paint.+ Pi `cost.total` is list-price; SuperGrok on graff is `$0.0000` flat-rate.- `capabilities` — feature gates; a task listing `requires` a capability isskipped on harnesses that lack it (e.g. `output-schema` structured outputs).diff --git a/graff-evals/harnesses.json b/graff-evals/harnesses.jsonindex d7acd580..9e8042a7 100644--- a/graff-evals/harnesses.json+++ b/graff-evals/harnesses.json@@ -127,5 +127,13 @@"capabilities": [],"default_model": "gemini-3.7-flash","note": "uses ~/.pi/agent/models.json provider codegraff → gateway.codegraff.com; Gemini tool loops need the codegraff-gemini-echo extension"+ },+ "pi-xai": {+ "cmd": ["{repo}/graff-evals/pi-xai.sh", "-p", "--mode", "json", "--provider", "xai", "--model", "{model}", "--no-session", "{prompt}"],+ "answer": "pi-json",+ "usage": "pi-json",+ "capabilities": [],+ "default_model": "grok-4.6",+ "note": "same SuperGrok seat as graff-dev. Wrapper reads graff-oauth.json into XAI_API_KEY. `pi` must be on PATH."}}diff --git a/graff-evals/pi-extensions/README.md b/graff-evals/pi-extensions/README.mdindex 81a0a1f0..acfacdc4 100644--- a/graff-evals/pi-extensions/README.md+++ b/graff-evals/pi-extensions/README.md@@ -20,3 +20,11 @@ Smoke:```bashpython3 graff-evals/run.py --harness pi-codegraff --model gemini-3.7-flash --task fix-fib```++For a same-seat SWE A/B against graff (SuperGrok / grok-4.6), skip the+gateway and use `pi-xai`:++```bash+# pi-xai.sh reads ~/.xai/credentials/graff-oauth.json (same as `graff login xai`)+cd graff-evals && ./run.py --suite swe --harness graff-dev,pi-xai --model grok-4.6 -j 6+```diff --git a/graff-evals/pi-xai.sh b/graff-evals/pi-xai.shnew file mode 100755index 00000000..3d3e6aa0--- /dev/null+++ b/graff-evals/pi-xai.sh@@ -0,0 +1,24 @@+#!/bin/sh+# Drive Pi on graff's SuperGrok seat (same-login A/B as ADR 0024 grok-build).+# Reads ~/.xai/credentials/graff-oauth.json unless XAI_API_KEY is already set.+set -e+oauth="${GRAFF_XAI_OAUTH:-$HOME/.xai/credentials/graff-oauth.json}"+if [ -z "${XAI_API_KEY:-}" ] && [ -f "$oauth" ]; then+ XAI_API_KEY=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["access_token"])' "$oauth")+ export XAI_API_KEY+fi+if [ -z "${XAI_API_KEY:-}" ]; then+ echo "pi-xai: no XAI_API_KEY and no $oauth — run \`graff login xai\`" >&2+ exit 127+fi+if [ -n "${PI:-}" ]; then+ exec "$PI" "$@"+fi+if command -v pi >/dev/null 2>&1; then+ exec pi "$@"+fi+if [ -x "$HOME/.local/bin/pi" ]; then+ exec "$HOME/.local/bin/pi" "$@"+fi+echo "pi-xai: pi not found (install @earendil-works/pi-coding-agent)" >&2+exit 127diff --git a/graff-evals/run.py b/graff-evals/run.pyindex 27dbc7a9..666ef9bd 100755--- a/graff-evals/run.py+++ b/graff-evals/run.py@@ -10,6 +10,7 @@ outcome, and writes JSONL results plus a summary table../run.py --harness graff --model grok-4.6 # full suite (core + rlm + swe)./run.py --suite rlm --harness graff-dev-old,graff-dev # scatter-gather A/B./run.py --suite swe --harness graff-dev-old,graff-dev -j 12 # DeepSWE-shaped A/B, parallel+ ./run.py --suite swe --harness graff-dev,pi-xai --model grok-4.6 -j 6 # same SuperGrok seat./run.py --suite mcp --harness graff-dev-old-nolean,graff-dev-rlm-struct,graff-dev-nolean./run.py --harness grok --task fix-fib --reps 3 # one task, 3 reps./run.py --interactive # pick + watch livediff --git a/graff-evals/seed-pi-xai.py b/graff-evals/seed-pi-xai.pynew file mode 100755index 00000000..1f90b847--- /dev/null+++ b/graff-evals/seed-pi-xai.py@@ -0,0 +1,57 @@+#!/usr/bin/env python3+"""Map graff's SuperGrok OAuth into Pi's auth.json (same seat as graff-dev).++`graff login xai` writes ~/.xai/credentials/graff-oauth.json (grok-build's+public client). ADR 0024 mapped that file into ~/.grok/auth.json for the+grok-build A/B. This writes ~/.pi/agent/auth.json as type=api_key: stock+Pi xai is an API-key provider and ignores type=oauth ("No API key for+provider: xai"). The SuperGrok access token is accepted as Bearer.++The eval path is `pi-xai.sh` (XAI_API_KEY). This mapper is optional.++Does not print tokens. Overwrites only the `xai` key; other providers stay.+"""+from __future__ import annotations++import json+import os+import stat+import sys+from pathlib import Path++GRAFF = Path.home() / ".xai/credentials/graff-oauth.json"+PI_AUTH = Path.home() / ".pi/agent/auth.json"+++def main() -> int:+ if not GRAFF.is_file():+ print(f"no SuperGrok OAuth at {GRAFF} — run `graff login xai`", file=sys.stderr)+ return 1+ src = json.loads(GRAFF.read_text())+ access = src.get("access_token") or ""+ if not access:+ print("graff-oauth.json has no access_token", file=sys.stderr)+ return 1+ PI_AUTH.parent.mkdir(parents=True, exist_ok=True)+ data = {}+ if PI_AUTH.is_file():+ try:+ data = json.loads(PI_AUTH.read_text())+ except json.JSONDecodeError:+ data = {}+ if not isinstance(data, dict):+ data = {}+ # Built-in xai is an API-key provider. The SuperGrok access token is+ # accepted as XAI_API_KEY / auth.json key (same Bearer graff sends).+ # OAuth type is ignored by stock xai ("No API key for provider: xai").+ data["xai"] = {"type": "api_key", "key": access}+ tmp = PI_AUTH.with_suffix(".json.tmp")+ tmp.write_text(json.dumps(data, indent=2) + "\n")+ os.chmod(tmp, stat.S_IRUSR | stat.S_IWUSR)+ tmp.replace(PI_AUTH)+ print(f"wrote {PI_AUTH} (xai api_key from graff-oauth.json)")+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())