Repository navigation
Description
Register agent type pi and implement PiAgent.executeTask so implementation tasks and PR follow-ups run through Pi in JSON mode, with the complete trace persisted.
Acceptance:
piis added to the shared agent type,createAgentFromConfig, default config paths (~/.pi/agent), agent constants, model definitions/aliases/label resolution, the PR template agent naming and the API types.- Invocation:
pi -p --mode json --model <provider/id>[:<thinking>] --thinking <level> --session-dir <runtime sessions dir> --no-approve, with the prompt via stdin or an@filemounted read-only. Map ProPR reasoning levels tooff|minimal|low|medium|high|xhigh|max. - Project trust: always pass
--no-approve, so repository-provided.pi/extensions, settings and prompts are never trusted. AGENTS.md/CLAUDE.md context files still load, which is desired. - Model IDs: use a ProPR-side id scheme (e.g.
pi-<provider>/<model>, mapped to--model <provider>/<model>), configured per agent insupportedModels, with sensible defaults. Labels in PR titles show the underlying model. - Output parser for the JSON event stream (see the fixture in the notes):
- session id from the
sessionheader; - summary from the last assistant
message_endtext; - success when
agent_settled.abortedis false, the process exited 0 and the last assistantstopReasonis noterror/aborted; - token usage summed over all assistant
message_end.message.usagerecords (input,output,cacheRead→ cache_read_input_tokens,cacheWrite→ cache_creation_input_tokens), since usage is per response, not cumulative; - cost from
usage.cost.totalwhentotalFromProvider(else ProPR pricing).
- session id from the
- conversationLog: Claude-shaped events, persisted as LLM log details so
get_task_logsshows them:- user message;
- assistant text and thinking;
- each
toolCall→tool_use(name, arguments); - each
tool_execution_endortoolResultmessage →tool_resultwithis_errorfromisError.
- The activity watchdog and output-activity detection recognise Pi events, so long tool runs aren't treated as stalls.
- Tests: parser and result tests built from the fixture (tool pairs including the failed bash call, token sums, session id, success); Docker args tests (flags, mounts,
--no-approve, no root-owned paths).
Implementation
Follow OpenCodeAgent/VibeAgent structure: a docker args builder, an output parser module under packages/core/src/agents/impl/utils/, and the result processing that feeds recordLLMMetrics. Persist the fixture as test/fixtures/pi/pi-1.6.1-json-tool-task.jsonl.
Notes
Fixture: a real Pi 1.6.1 run via OpenRouter (mistralai/devstral-2512), trimmed to one example of each record type (paths sanitized):
{"type":"session","version":3,"id":"01a21d71-9198-74eb-978e-565639986934","timestamp":"2026-11-27T14:38:31.832Z","cwd":"/home/node/workspace"}
{"type":"agent_start"}
{"type":"turn_start"}
{"type":"message_end","message":{"role":"user","content":[{"type":"text","text":"Read math.js, add subtract(a, b) next to add and export it, add a node:test test in math.test.js, then run node --test. Also run 'cat missing.txt' once."}],"timestamp":1795790311889}}
{"type":"message_update","usage":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"totalTokens":0,"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0}},"assistantMessageEvent":{"type":"toolcall_start","contentIndex":0,"id":"HEFIeQfFW","toolName":"read"}}
{"type":"message_update","usage":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"totalTokens":0,"cost":{"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0}},"assistantMessageEvent":{"type":"toolcall_delta","contentIndex":0,"delta":""}}
{"type":"message_end","message":{"role":"assistant","content":[{"type":"toolCall","id":"HEFIeQfFW","name":"read","arguments":{"path":"math.js","offset":1,"limit":50}},{"type":"toolCall","id":"7Rc4Yw8fp","name":"read","arguments":{"path":"math.test.js","offset":1,"limit":50}},{"type":"toolCall","id":"4vK53wBZb","name":"bash","arguments":{"command":"cat missing.txt","timeout":5}}],"api":"openai-completions","provider":"openrouter","model":"mistralai/devstral-2512","usage":{"input":1583,"output":65,"cacheRead":0,"cacheWrite":0,"reasoning":0,"totalTokens":1648,"cost":{"input":0.0006332000000000001,"output":0.00013,"cacheRead":0,"cacheWrite":0,"total":0.000755568,"totalFromProvider":true}},"stopReason":"toolUse","timestamp":1795790311916,"responseId":"gen-1795790312-9VMDdqzYpui5kDqt0P0f","rawStopReason":"tool_calls","durationMs":2080,"thinkingLevel":"off"}}
{"type":"tool_execution_start","toolCallId":"HEFIeQfFW","toolName":"read","args":{"path":"math.js","offset":1,"limit":50}}
{"type":"tool_execution_update","toolCallId":"4vK53wBZb","toolName":"bash","args":{"command":"cat missing.txt","timeout":5},"partialResult":"<trimmed>"}
{"type":"tool_execution_end","toolCallId":"4vK53wBZb","toolName":"bash","result":{"content":[{"type":"text","text":"cat: missing.txt: No such file or directory\n\n\nCommand exited with code 1"}],"structuredContent":{"output":"cat: missing.txt: No such file or directory\n","truncated":false,"exit_code":1,"wall_time_seconds":0},"isError":true},"isError":true,"durationMs":17}
{"type":"tool_execution_end","toolCallId":"6UNoPXH4u","toolName":"edit","result":{"content":[{"type":"text","text":"Successfully replaced 1 block(s) in math.js."}],"details":{"diff":"...","firstChangedLine":5}},"isError":false,"durationMs":13}
{"type":"message_end","message":{"role":"toolResult","toolCallId":"HEFIeQfFW","toolName":"read","content":[{"type":"text","text":"function add(a, b) {\n return a + b;\n}\n\nmodule.exports = { add };\n"}],"isError":false,"durationMs":19,"timestamp":1795790314021}}
{"type":"turn_end","message":"<trimmed>","toolResults":[{"role":"toolResult","toolCallId":"4vK53wBZb","toolName":"bash","content":[{"type":"text","text":"cat: missing.txt: No such file or directory\n\n\nCommand exited with code 1"}],"isError":true,"durationMs":17,"timestamp":1795790314022}]}
{"type":"message_end","message":{"role":"assistant","content":[{"type":"text","text":"Done. Added subtract(a, b) to math.js, exported it, and added a test; node --test passes."}],"api":"openai-completions","provider":"openrouter","model":"mistralai/devstral-2512","usage":{"input":2202,"output":164,"cacheRead":0,"cacheWrite":0,"reasoning":0,"totalTokens":2366,"cost":{"input":0.0008808,"output":0.000328,"cacheRead":0,"cacheWrite":0,"total":0.001196712,"totalFromProvider":true}},"stopReason":"stop","timestamp":1795790316556,"responseId":"gen-1795790316-uvu8unnsQlnQFhumFWZy","rawStopReason":"stop","durationMs":2016,"thinkingLevel":"off"}}
{"type":"agent_end","messages":["<trimmed>"],"willRetry":false}
{"type":"agent_settled","aborted":false}The full event reference is in the package's docs/json.md: message_update.assistantMessageEvent types text_*, thinking_* and toolcall_*; tool_execution_*; compaction and retry events. ProPR runs on SQLite only: do not add code or tests for other databases.
Activity
chore: install Pi CLI in agent image with disposable runtime
[3831 by Claude Opus 5.5] Pi: install the CLI in the agent image with…
propr-dev commentedon Nov 27, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-53832/claude-opus-5-5-pi-agent-type-and-piagent-20261127-1622-0nl3831-epic-pi-coding-jmlissue-3832-20261127-1622-claude-opus-5-5-0nl🔍 Track Task Execution