Skip to main content

GAP gives Grok Bot a Pi apprentice for heavy work and a webhook for review

XXepluribusyao (Eric)2026-11-12

Code and reposLimitsSource read in fullRead first

Overview

When Grok Bot searches folders, runs tests, and reads errors itself, routine work uses its conversation context and quota. Long jobs can quietly die if the machine sleeps or loses its connection.

Workflow

The idea comes from Chasen Liao's open-source GAP (Grokbot And Pi). The large model plans and inspects, and a lightweight coding agent on the same machine does the work.

  1. Grok Bot does three things: Write the ticket, give it to Pi, and sign off after checking (ack). Pi never deletes files, sends email, makes payments, or runs git push. Grok Bot checks and performs these irreversible actions itself after explicit confirmation from the author.
  2. The Pi apprentice (pi-coding-agent v1.5.2): It runs headless on Grok Bot's Linux cloud computer, reads and writes the workspace directly, and runs bash.
  3. Magpie model gateway: Deploy on a small AWS server (1 core, 2GB) and keep it running as a systemd user service. Bind only to the private Tailscale address without exposing a public port. Pass the Gemini key as an environment variable.
  4. Private Tailscale network: Grok Bot's computer accesses the gateway through the Tailscale plugin and MagicDNS name.
  5. Completion webhook: Create a Webhook Routine called Pi task completion wake. Dispatch with --notify-prefix GROKBOT so a POST wakes Grok Bot for review when work finishes or needs human approval. pi-task manages the task lifecycle and stores state in ~/.pi/tasks/<id>/. pi-guard intercepts dangerous commands such as rm -rf before each Pi tool call.
  6. Smoke test: Ask Pi to write gap-ok to /tmp/gap-smoke.txt. Preflight passes, Pi writes the file, the webhook returns HTTP 200, the Routine wakes and uses cat to read gap-ok, pi-task ack archives it, and pending is empty.
  7. Choose a model by task. Grok Bot assesses complexity before dispatch and explicitly passes --model. Use a cheap, fast model for 90%+ of routine work, an expensive model for complex reasoning or long context, and a fallback when upstream is congested. Save two skills: grokbot-pi-dispatch to choose the model, dispatch, wait, and review, and grokbot-pi-setup to check the environment, install, and validate configuration.
  8. Check: The bot reads result.md and runs git diff and the unit tests itself before acknowledging.

Key points and results

  • Four pitfalls:
    • The raw Tailscale IP kept timing out. The cloud computer depends on the desktop-side Tailscale plugin. Use the full MagicDNS name instead of installing another Tailscale client on the host.
    • magpie provider test google returned 404 because the default test model hardcoded in Magpie had been retired. The key was fine.
    • Calls hung for over 100 seconds. Magpie silently retried with exponential backoff on upstream 503s, and AI Studio's free tier was rate-limited with 429 after 20 requests per day for that model. Pay-as-you-go returned in about 2 seconds. The author says the cheapest option can end up costing the most.
    • The author deliberately avoided a risk: proxying a personal consumer subscription through a gateway might violate Google's terms. Use an officially billed API key.
  • Blocking waits consume no conversation quota. Grok Bot waits up to 13 minutes through a blocking call after dispatch, which also keeps the machine from sleeping while idle. A webhook wakes the bot for review even if the conversation is interrupted.
  • Result (author's claim, not reproduced): Routine work cost roughly an order of magnitude less. The author gives no billing figures.
  • Smallest starting setup: Install Pi on the agent's machine, connect a paid model, and get the gap-ok smoke test to pass.

Source

Platform
X
Author
epluribusyao (Eric)
Published
Categories
Code and repos, Limits

What this evidence label means

Source read in full

We read the source (post, article or transcript). That only means the original was read. It does not mean this site reproduced the author's results.

Read the editorial and evidence policy

Other cases in this scenario

This unofficial community project is independent of xAI. xAI has neither approved nor endorsed it. No sign-up. The methods and figures come from the original authors.