Skip to content

Add Pi coding agent backend support#8

Open
jjar1 wants to merge 3 commits into
danshapiro:mainfrom
jjar1:main
Open

Add Pi coding agent backend support#8
jjar1 wants to merge 3 commits into
danshapiro:mainfrom
jjar1:main

Conversation

@jjar1
Copy link
Copy Markdown

@jjar1 jjar1 commented May 4, 2026

Summary

Adds Pi (pi coding agent) as a fifth backend to trycycle, enabling trycycle to run as both host agent and subagent backend.

Changes

  • Pi backend (subagent_runner.py): probe, run, resume, session extraction, host detection via PI_CODING_AGENT env var
  • Pi transcript adapter (pi_cli.py): canary-based search of Pi session JSONL files
  • Registration: build.py (ADAPTERS) and run_phase.py (CLI choices)
  • SKILL.md rewrite: Pi-only, fallback-runner-only
  • Tests: 35 new Pi-specific tests (8 backend, 8 transcript adapter, 9 SKILL.md acceptance, 10 registration/integration). All 119 tests pass.

Quality

  • Ruff clean
  • Only pre-existing mypy errors remain (7 in upstream code)
  • Full spec: .ralph/specs/pi-backend.md

Test added 3 commits May 4, 2026 18:38
Implemented:
- _probe_pi(): probes pi --help for required tokens (--print, --session, --session-dir, --no-skills, --model)
- _pi_command(): builds pi -p --session-dir --no-skills --no-extensions --no-prompt-templates --no-context-files
- _pi_resume_command(): builds pi -p --session <id> with isolation flags
- _extract_pi_session_id(): extracts session ID from JSONL header in artifacts dir
- Host detection: PI_CODING_AGENT=true detected first in _detect_host_backend()
- Model override: TRYCYCLE_PI_MODEL env var, supports pi's model:thinking syntax
- Transcript adapter pi_cli.py: canary-based search + turn extraction from Pi JSONL
- Registration: pi in build.py ADAPTERS, pi-cli/pi in run_phase.py choices
- 8 new PiBackendTests (probe, host detection, run, resume, model override, failure)
- Fixed 8 existing tests that leaked PI_CODING_AGENT=true from real env

Tests: 92 passed, 4 skipped. Ruff clean. Mypy clean on new code.
- Remove all Claude Code / Codex / Kimi / OpenCode backend references
- Remove all native-mode branches and choice points
- Simplify phase wrapper to always use run_phase.py run (fallback-runner)
- Simplify transcript helper to always use pi-cli with canary
- Simplify subagent defaults to always use --backend host, TRYCYCLE_PI_MODEL
- Remove non-Pi model env vars (TRYCYCLE_CODEX_*, TRYCYCLE_CLAUDE_*, etc.)
- Preserve all critical rules (timeout, no kill, no busy-poll)
- Add 9 tests validating acceptance criteria in test_skill_md_pi_only.py
- 101 tests pass (92 original + 9 new)
… pattern

Tests cover: canary session discovery, multi-turn extraction, thinking/
toolCall filtering, non-message record skipping, missing sessions root,
canary timeout, _encode_cwd path encoding, and last-assistant-per-interval
semantics. 119 total tests pass (up from 101).
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.

1 participant