Skip to content

feat: implement Pi as a sandbox external agent (#2426) - #2550

Merged
yannickmonney merged 1 commit into
mainfrom
feat/pi-external-agent-2426
Jul 7, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
feat/pi-external-agent-2426

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2426

Adds Pi (the pi coding agent, @earendil-works/pi-coding-agent, pinned 0.80.3) as a sandbox external-agent runtime with Claude Code parity, following the Hermes (#2500) / Gemini CLI (#2535) / Codex (#2536) pattern.

What ships

  • Adapter services/platform/lib/agent-adapters/pi/ — buildExec + stream parser + tests, and fixtures/pi/shell-turn.jsonl captured from a real pinned-CLI run against a mock OpenAI-completions gateway (the bash tool call executed for real; ids/timestamps sanitized).
  • Wrapper services/sandbox-runtime/tale-pi-run — stages a private per-exec config dir (PI_CODING_AGENT_DIR) holding models.json / settings.json / APPEND_SYSTEM.md, pins a stable PI_CODING_AGENT_SESSION_DIR for resume, and pipes the prompt into pi --mode json stdin. Prompt and system-prompt append ride stdin/staged files, never argv.
  • Managed — gateway OpenAI-compatible route wired as a Pi custom provider (models.json baseUrl <gateway>/openai/v1, apiKey "$TALE_GATEWAY_TOKEN" env interpolation, so the staged file never contains the key), pinned via --provider tale-gateway --model <gateway id>.
  • BYO — no gateway config; Pi's env inference picks the user's credentials (OPENROUTER_API_KEY / ANTHROPIC_API_KEY / OPENAI_API_KEY / GEMINI_API_KEY). byoModelIdSource: 'catalog': the shipped catalog refs resolve to ids Pi's built-in openrouter catalog speaks verbatim (anthropic/claude-sonnet-4.6 is a literal model id at v0.80.3).
  • Resume — parser captures the session id from the session header; next turn passes --session <id> (local-then-global lookup, verified in 0.80.3 source and exercised locally through the wrapper: same session id, full prior context replayed).
  • Platform wiring — agentKind: 'pi' appended last in every union/validator/registry, agent-editor kind option, readiness types, builtin-configs/agents/chat/pi.json (managed, composer order 45, Claude Sonnet 4.6 + Opus 4.8 like Hermes), Dockerfile pin + wrapper, container runtime checks (PATH/version + AST flag-drift guard against the pinned pi --help), docs en/de/fr + frontmatter manifest, locale label agents.form.agentKind.pi.

Verified against the pinned CLI (0.80.3 source + real runs)

  • --mode json event shapes (session header, message_update/message_end, tool_execution_*, agent_end, auto_retry_*) — parser built from a real captured run.
  • Auto-retry semantics: a failed model call ends its cycle with a normal agent_end and pi may retry; the parser holds an error result open until the stream ends (or auto_retry_end fails) so a recovered turn reports completed exactly once.
  • APPEND_SYSTEM.md appends to the default system prompt (verified in the request body of a real run) — spec.systemPromptAppend demonstrably reaches the model.
  • models.json value resolution ($ENV_VAR interpolation) — verified: Authorization: Bearer <session key> on the wire, key absent from staged JSON.
  • Pi has no MCP, no native web tools, no interactive-question tool (built-ins: read/bash/edit/write/grep/find/ls) — so there is nothing to deny for managed/headless runs and no integrations-MCP/Playwright wiring; integrations ride the runtime-agnostic skills bridge (skillsStageDir: ~/.agents/skills, an always-trusted homedir location independent of the config-dir override).
  • No usage event is ever emitted for zero-token messages; no fallback behaviour is claimed anywhere (Pi has no availability-fallback chain; fallbackModel and maxTurns are deliberately ignored and documented as such).

Verification

  • vitest on agent-adapters, shared schemas/readiness, external_agent, sandbox, model-selector, i18n: 1433 passed; docs suite: 166 passed (frontmatter manifest guarded).
  • Platform tsc --noEmit clean; oxlint clean on all touched paths; knip and format:check green.
  • Wrapper exercised end-to-end locally with the real 0.80.3 CLI against a mock gateway (managed turn + resume turn), and the container test's flag-drift check validated locally against the pinned pi --help.

Not provable locally: sandbox image build (Docker), live gateway metering/VK mint, real BYO provider calls — the container-runtime integration test covers image assertions in CI.

Add Pi (@earendil-works/pi-coding-agent, pinned 0.80.3) as an external-agent
runtime with Claude Code parity: gateway-managed turns (VK + metering) over
the OpenAI-compatible route via a per-exec staged models.json provider, BYO
via the user's own credentials (catalog model-id dialect), multi-turn resume
(--session + a stable PI_CODING_AGENT_SESSION_DIR), normalized events with
auto-retry-aware result mapping, per-exec APPEND_SYSTEM.md for the
system-prompt append, docs in en/de/fr, and a parser fixture captured from a
real pinned-CLI run against a mock gateway.
@yannickmonney
yannickmonney merged commit 4eff638 into main Jul 7, 2026
15 of 18 checks passed
@yannickmonney
yannickmonney deleted the feat/pi-external-agent-2426 branch July 7, 2026 12:02
yannickmonney added a commit that referenced this pull request Jul 7, 2026
…leet

The budget was set at 4400 MB when the image was ~4.0 GB; the six external
agent CLIs added since (Cursor #2481, Hermes #2500, Gemini #2535, Codex
#2536, Pi #2550, OpenClaw #2555) grew it to ~4.9 GB and none of those PRs
updated the budget, so the Validate images gate is red on main too. Document
the fleet as a named cost and restore the ~10% headroom convention at 5400.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Implement Pi as a sandbox external agent (Claude Code parity)

1 participant