بنقرة واحدة
pi-agent
Delegate coding/tasks to pi CLI over RPC with persistent, resumable sessions.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Delegate coding/tasks to pi CLI over RPC with persistent, resumable sessions.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
MCP server providing browser automation tools that bypass Cloudflare, LinkedIn, Indeed, and other WAF-protected sites using agent-browser with anti-detection stealth.
Browser automation via agent-browser CLI (Vercel Labs). Headless Chrome navigation, snapshots, clicks, fills, screenshots, eval, and batch flows for web research, UI testing, and QA.
Manifest V3 Chrome extension that patches browser fingerprint vectors at document_start for WAF bypass
Hermes-native tool plugin for controlling pi --mode rpc sessions with full lifecycle management
Build three essential docs for AI agent context: personal constitution, goals, and business strategy. Based on Allie Miller's framework.
Prevent silent context-window pressure and the '18,000 character trap' by enforcing file size discipline on skills, .env, SOUL.md, and config files. Inspired by Andrew's OpenClaw Blueprint series.
| name | pi-agent |
| description | Delegate coding/tasks to pi CLI over RPC with persistent, resumable sessions. |
| version | 1.0.0 |
| author | Dustin Chadwick (@ShaggyD) |
| license | MIT |
| metadata | {"hermes":{"tags":["Coding-Agent","RPC","Session-Continuity","Automation","JSONL"],"related_skills":["opencode","codex","hermes-agent"]}} |
Use pi --mode rpc for a long-lived, bidirectional coding agent process with durable session continuity and machine-readable events.
Remote coding agents lose state when sessions break or auth expires. Running pi in RPC mode means managing JSON event streams, remembering session file paths, and wiring up stdin/stdout yourself. When something fails, the whole session is gone.
Complete coverage of the pi RPC protocol: session lifecycle (start, resume, fork), JSON command structure, event stream parsing, response extraction, and failure recovery patterns. Includes the native Hermes pi_agent tool plugin for full lifecycle management without manual process wrangling.
Your coding agent survives terminal restarts, auth reconnects, and network blips without losing context. Sessions are resumable, events are structured, and the failure modes you'd hit on day one are already handled.
message_update, tool_execution_*, turn_end)fork) and session switching (switch_session)pi CLI installed and on PATHpi --mode rpc --help--no-sessionsessionFile from get_state.pi --mode rpc --session <sessionFile>.Fallback: pi --mode rpc -c resumes the latest session.
# new session in current directory
pi --mode rpc
# new session in a specific project directory
cd ~/code/my-project && pi --mode rpc
# resume exact session
pi --mode rpc --session /path/to/session.jsonl
# resume last session
pi --mode rpc -c
{"type":"prompt","message":"Summarize failing tests and suggest fixes."}
{"type":"get_state"}
{"type":"get_session_stats"}
{"type":"get_fork_messages"}
{"type":"fork","entryId":"abc123"}
Important: the prompt payload key is
message(notprompt). Usingpromptcan fail with runtime errors in current pi builds.
agent_start / agent_endturn_start / turn_endmessage_update (streaming text/tool deltas)tool_execution_start / tool_execution_update / tool_execution_endcompaction_start / compaction_endUse turn_end or agent_end as completion boundaries for a prompt cycle.
pi_agent tool (preferred)Use the built-in stateful tool when available:
action: start — launch pi --mode rpc in a specific workdir (optional pi_session_path, provider, model)action: send — send message or raw command JSON; auto-assigns/accepts request_idaction: poll — incremental event retrieval with cursor/offset semanticsaction: wait — block until completion boundary (default until_event="turn_end") with timeoutaction: list — inspect active + detached sessionsaction: resume — revive a detached session by starting a new live process (uses saved sessionFile when available; otherwise starts fresh in the same workdir and returns a warning)action: prune — remove stale detached metadata entries older than max_age_days (default 7)action: stop — terminate a live session{"action":"start","workdir":"/home/dchadwick/dev/thoughtspace"}
{"action":"send","session_id":"<SESSION_ID>","message":"Summarize the failing tests and propose the smallest fix.","request_id":"req-1"}
{"action":"wait","session_id":"<SESSION_ID>","request_id":"req-1","until_event":"turn_end","timeout_seconds":90}
{"action":"poll","session_id":"<SESSION_ID>","limit":200}
{"action":"list"}
{"action":"resume","session_id":"<DETACHED_SESSION_ID>"}
{"action":"prune","max_age_days":7}
{"action":"stop","session_id":"<SESSION_ID>"}
1) {"action":"start","workdir":"/path/to/repo"}
2) {"action":"send","session_id":"<SESSION_ID>","message":"...","request_id":"req-1"}
3) {"action":"wait","session_id":"<SESSION_ID>","request_id":"req-1","until_event":"turn_end","timeout_seconds":180}
4) {"action":"poll","session_id":"<SESSION_ID>","limit":200}
5) {"action":"stop","session_id":"<SESSION_ID>"}
For complex prompts (multi-turn research, file reading, test running): wait() returns massive streaming delta data (400K–800K+ chars) that gets truncated. The clean text response is in the session JSONL file — see references/response-extraction.md for how to extract it. Add a 6th step: extract from session file after turn_end.
1) start → 2) send → 3) wait (until turn_end) → 4) extract text from session file → 5) poll (to sync) → 6) stop
Simple prompts (one-shot code gen) resolve in 15–30s and the text is available directly in wait() output.
If native pi_agent is unavailable, run pi in a Hermes background process and interact with process:
terminal(..., background=true, pty=false)process(action="submit", data='{"type":"prompt",...}')process(action="poll"|"log")process(action="kill")pi_agent tool runtime behavior (important)~/.hermes/state/pi_agent_sessions.json.send will fail) because stdio handles cannot be reattached safely.action: resume on a detached session to spawn a new live RPC process:
sessionFile (--session <file>) for continuitysessionFile is missing, starts a fresh RPC process in the same workdir and returns a warningaction: prune periodically to remove stale detached metadata (max_age_days, default 7).RPC sessions inherit the current working directory unless explicitly set. For project-specific work, start pi in the target repo directory.
Examples:
cd ~/dev/thoughtspace && pi --mode rpc
# or from wrappers/scripts: subprocess.Popen(..., cwd="~/dev/thoughtspace")
Without this, repository checks (branch status, diffs, tests) may run in the wrong location.
For opencode-go, credentials should be available to the spawned pi process via one of these:
~/.pi/agent/auth.json provider entries (preferred):{
"opencode-go": { "type": "api_key", "key": "..." },
"opencode": { "type": "api_key", "key": "..." }
}
OPENCODE_API_KEY in the process environment.If using a Python wrapper, do not assume shell startup files are loaded — explicitly pass env=... to subprocess.Popen(...) and/or load .env yourself.
Use message for type: "prompt" payloads:
{"type": "prompt", "message": "Hello"}
Using {"prompt": ...} can fail with provider/runtime errors.
Delegate git operations to pi — don't run them yourself via terminal
"Stage these files, commit with message X. Then stage these, commit with message Y. Do them in order." — pi executes them sequentially, each as its own turn.npm test (or equivalent) after any code change before committing. Dusty explicitly emphasizes this. If pi agent made the changes, ask it to run tests as the final step of the commit workflow.git add / git commit yourself via the terminal tool when pi is available for the repo. The user expects the agent to do the git work.Distinguish poll noise from genuine model slowness
poll() while a turn is in progress, you'll see character-level thinking_delta events and tool stdout streaming — this is intermediate streaming events, not the agent typing slowly. Some agents finish fast; you're just reading raw event fragments.send() the prompt, then wait(until_event='turn_end') to block for completion, then poll() for the final result. The time between send and turn_end is the true wall-clock time — not what the character deltas suggest.poll() during an active turn shows every message_update (thinking fragment by fragment), tool_execution_update (stdout line by line). These make the agent look glacially slow when it's actually running at normal speed.total_seen increasing — don't read the individual delta events.references/model-escalation.md): switch to a stronger model, re-send the prompt, switch back after breakthroughFollow user-specified escalation paths — don't kill the agent
set_model command to switch to the escalation model, re-send the prompt, then set_model back after breakthrough.references/model-escalation.md for exact commands and lifecycle.Mixing logs and JSON on stdout
Forgetting to persist sessionFile
-c).Assuming one response line per command
id/command response.Using --no-session accidentally
Launching in the wrong repository
cwd in your wrapper), otherwise branch/diff analysis is against the wrong repo.wait() returns massive output for multi-turn prompts
wait() response bundles all streaming deltas — think fragments, partial tool calls, text — into one 400K–800K+ char blob. This gets truncated in tool output.timeout_seconds to 180+ for research prompts. Extract the clean final text from the session JSONL file instead of parsing wait() output (see references/response-extraction.md).Auth looks like transport failure
No API key found for unknown, RPC is healthy but provider auth is missing. Fix auth first (OPENCODE_API_KEY or pi /login) before debugging your wrapper.start spawns a live pi process that sits in the background until killed. Over a long session you can accumulate 5–10 orphaned pi processes consuming RAM and file handles.stop sessions when done with them. Use action: stop with session_id.action: list to see all sessions, then action: stop on each stale one. Or kill by PID: ps aux | grep 'pi.*rpc' | grep -v grep then kill <PID>.action: prune command only removes detached metadata entries (session file references), not live processes. Use action: stop for live sessions.See references/rpc-pitfalls.md for concrete error transcripts and fast triage checks.
references/auth-and-extension-troubleshooting.md — common auth and extension startup failures, plus deterministic fixes.references/response-extraction.md — extracting pi's final text response from the session JSONL file when wait() returns truncated streaming delta data.references/hermes-stateful-tool-integration.md — native Hermes pi_agent tool wiring (start/send/poll/wait/stop/list), registry verification, persistence file, and restart gotchas (detached sessions).references/rpc-pitfalls.md — concrete error transcripts and fast triage checks for RPC issues.references/model-escalation.md — switching mid-session between models (cheap → strong → back) when the user specifies an escalation path.references/model-capability-discovery.md — testing which models support vision, transcription, or other capabilities; cost comparison before choosing a model.pi --mode rpc --help worksget_state returns a sessionFile--session <that file> succeedsturn_end or agent_endfork and switch_session tested if workflow needs branching