Repository navigation
[3832 by Claude Opus 5.5] Pi: agent type and PiAgent implementation for tasks, with full persisted execution events - #3849
Conversation
I've registered `pi` as a full agent type, and implementation tasks and PR follow-ups now run through Pi in JSON mode with the whole trace saved as execution events. The new tests pass (23 of 23). So do the existing suites I picked that touch agent types, models, reasoning levels, metrics, the watchdog and the CLI, plus the propr-ui Settings/config tests. Typecheck passes for every package and lint passes for core and root `src/`. I did not run a real containerised Pi task: there's no Docker here, so the full in-image run hasn't happened yet. Agent type. `pi` is now in the shared and core type lists, `createAgentFromConfig`, the default config path (`~/.pi/agent`, overridable with `PI_CONFIG_PATH`/`HOST_PI_DIR`), the in-container path, the health-check models, the PR template's agent name, and the CLI and UI types. Now that `pi` is a real agent type, I removed the temporary image-only `pi` entry that #3839 added; `AgentCliType` is now just an alias for the agent type. Invocation. Each run is `pi -p --mode json --model <provider/id> [--thinking <level>] --session-dir /tmp/propr-pi-home/agent/sessions --no-approve`, with the prompt on stdin. - Reasoning levels: `low` through `max` pass straight through. `ultra` and `ultracode` run at `max`. Unset or `auto` leaves the model's own default. - Docker: the container starts as root only so the existing entrypoint can set up the per-run Pi home, then Pi runs as `node`. - Pi config dir: mounted only if it exists on the host, because Docker would otherwise create it there owned by root. It is mounted read-write so the entrypoint can write refreshed sign-in tokens back. - Secrets: the GitHub token and provider API keys go in through the Docker client's environment, so they never appear in the command line. - Analysis runs: read-only workspace and no saved session. They get no tools, or only `read,grep,find,ls` when the caller allows read-only inspection. Model IDs. These use the form `pi-<provider>/<model>`, with an optional `:<thinking>` suffix. The defaults are Opus 5.5, Sonnet 5.5, GPT-6.2 Astra, Gemini 4 Argon and Devstral 2 via OpenRouter. PR titles, aliases (e.g. `llm-pi-devstral2`) and pricing resolve to the underlying model. The startup config migration no longer drops Pi models that aren't in the catalog, and doesn't re-add default models an operator has removed. Parser. It reads the session id, summary, success rule, per-response token sums and provider cost exactly as the issue specifies. Each tool call gets exactly one result event: Pi reports a result in both `tool_execution_end` and a `toolResult` message, and `turn_end` repeats it, so duplicates are skipped. The failed `cat missing.txt` call is recorded with `is_error: true`. Things that behave differently from what you might assume: - Pi exits 0 even when the provider rejects the request. I checked this against a real Pi 1.6.1 run with a bad OpenRouter key: it ended with `stopReason: "error"` and exit code 0. The success rule catches this, and there's a test built from that output. - Provider cost needed a shared change. To use Pi's reported cost instead of ProPR pricing, I added a `providerCostUsd` field. It's passed through the result converters into `recordLLMMetrics`, which uses it before pricing. It is only set when every response says `totalFromProvider`, so other agents are unaffected. - Managed diagnostics skip Pi, because its sessions live in a per-run directory and the host dir holds nothing to inventory. - Context scouting stays off for Pi. It isn't added to the agents allowed to do repository scouting. Watchdog. Pi's `toolCall` blocks, `tool_execution_start`/`_end`, `toolResult` messages and `turn_end` results are now tracked as tool calls. A long-running tool is held to the longer tool threshold instead of being treated as a stall. Tests and docs. The fixture is at `test/fixtures/pi/pi-1.6.1-json-tool-task.jsonl` and the tests are in `test/piAgent.test.ts`. I updated two existing tests for the new type: a missing `pi` entry in `agentDefaultConfigPaths` and an expected error message in `apiOpenCodeRoutes`. `docs/docs/features/agents-and-models.md` now has a Pi row and a short Pi section. Not done: - Launcher and CLI setup plumbing for `HOST_PI_DIR` (orchestrator, `initStack`, `checkCommands`). - A Pi parser for the live output view in the API. - Pi-specific fields in the agent settings dialog. Pi does now appear in the agent type selector automatically. No preview was made: the only visible change is that new "Pi" option in the type selector. ProPR-Agent: claude/claude-opus-5-5
|
/ultrafix goal=8 max=8 |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 8) First action:
|
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
|
CI failed: Full Test Suite Shard 3/4 Please investigate and fix this CI failure.
Failure evidence
|
|
✅ Applied the requested follow-up changes in commit 4301cd9 Summary of ChangesI fixed the one failing test in shard 3. Everything else in the shard passed. Cause: Fix: I added I also searched the other tests for the same hard-coded list. No preview, since this only changes a test. Review digestRisk-tiered paths
Diff size: 1 file changed, +1/−1 lines 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
I fixed the one failing test in shard 3. Everything else in the shard passed. **Cause:** `test/cliAgentOpenCode.test.ts:29` checks the help text for the `agent add` command against a hard-coded list of agent types. This branch adds `pi`, so the help now reads `Agent type (claude, codex, antigravity, opencode, vibe, pi)`. The old pattern ended at `vibe)` and no longer matched. **Fix:** I added `pi` to the expected list in that pattern. The file now passes locally (3 of 3). I also searched the other tests for the same hard-coded list. `packages/cli/src/commands/setupCommand.test.ts` has a similar one, but it's for skill targets, not agent types. This branch doesn't add `pi` to that list, so I left it alone. No preview, since this only changes a test. PR: #3849 Comment by: @propr-dev[bot] (ID: 7224133308) Model: Claude Opus 5.5 ProPR-Agent: claude/claude-opus-5-5
|
CI failed: Validate unsigned linux-arm64 package Please investigate and fix this CI failure.
Failure evidence
|
|
ℹ️ Analyzed the follow-up request by @propr-dev[bot] Analysis SummaryThis failure has nothing to do with the Pi changes in this PR, so I didn't change any code. The CI job just needs a re-run, and I couldn't trigger one from here: What failed: one test in Why I think it's a one-off:
I couldn't run the test myself: this container has no Next step: re-run the failed jobs of run 46040453460, or push again to start a fresh run. If it fails the same way again, the cause would be on the runner side, and it would be worth seeing whether other branches hit it too. I saved a note about this failure to memory. There's no visual change, so no preview. No code changes were necessary based on the current state of the branch. 🤖 Analysis Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR adds Pi across agent registration, invocation, model routing, output parsing, and metrics. The approach is cohesive, but failure handling needs a localized correction before merge. ✅ Provider errors recognized — A zero process exit does not imply success: the parser also checks settlement, abort state, and the final assistant stop reason. ✅ Tool-result deduplication — Results repeated across Pi events are recorded once per tool-call ID, including their error status. ✅ Secret-safe arguments — Provider keys and scoped GitHub credentials are passed through the Docker client environment rather than embedded in arguments. The supplied current-head status reports 35 passed checks and 12 skipped, with no failures. This review used the supplied code only; no commands were run. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 Preserve results after post-execution failures
SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Exercise the actual container invocationAdd a container smoke test covering task execution and analysis, including credential import and execution as S2: 🟢 Record suffix-derived reasoningWhen a model ID supplies ScoreThe integration has useful focused coverage and passing current checks. Preserving completed execution data across later failures is necessary before merge. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit e7c9e7e
Summary of ChangesI fixed F1. When a Pi run has finished and something after it fails, the failed result now keeps what the run produced instead of discarding it. The new regression tests pass, and they fail against the previous Problem. Pi built the finished response inside the Changes:
Sibling check. Claude and Codex already keep the finished response this way and write the missing log row. Pi's Tests. The new file
All 4 pass, and 2 of them fail against the old One thing to know: when the log write itself is what fails, the failure path tries it once more. The Codex agent does the same. No preview was made, because nothing visible changed. Review digestRisk-tiered paths
Diff size: 3 files changed, +144/−5 lines 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
I fixed F1. When a Pi run has finished and something after it fails, the failed result now keeps what the run produced instead of discarding it. The new regression tests pass, and they fail against the previous `PiAgent.ts`. **Problem.** Pi built the finished response inside the `try`, so the `catch` couldn't see it. A rejecting `onSessionId` callback, or a failing log write, produced a failed result with no tokens, cost, session or conversation. In the callback case the run's log row was never written either. **Changes:** - **`packages/core/src/agents/impl/PiAgent.ts`:** - **What a failure keeps:** `executeTask` now holds the finished response outside the `try`. On any later failure it builds the result with the shared `failedExecutionResult` helper. That keeps the session id, conversation, token usage, cost, provider cost, provider model, reasoning level and execution id, and Pi also keeps the run's usage metrics. - **Failures before Pi produced output:** these keep the prompt and carry no run data, as before. - **Log row:** if the run finished but its log row was never written, it is now written once, marked failed, with Pi's provider cost. If that write fails too, a warning is logged and the failed result is still returned. - **`packages/core/src/agents/impl/utils/failedAgentExecution.ts`:** `failedExecutionResult` now also keeps `providerCostUsd`. Claude and Codex already route through this helper; they don't set that field today, so nothing changes for them. **Sibling check.** Claude and Codex already keep the finished response this way and write the missing log row. Pi's `analyze` path doesn't have the bug: it has no awaited step between building the result and returning it. **Tests.** The new file `test/piAgentPostExecutionFailure.test.ts` runs the real `executeTask` against the recorded Pi 1.6.1 trace, with only the Docker call replaced. It covers: - A rejecting session callback: the result keeps the run, and the log row is written exactly once. - A failing log write: the result still keeps the run. - Docker throwing before any output: the prompt is kept, there is no run data, and no row is written. - The shared helper keeping `providerCostUsd`. All 4 pass, and 2 of them fail against the old `PiAgent.ts`. `test/piAgent.test.ts` and `test/llmMetricsFailedExecutions.test.ts` still pass (30 of 30). The core typecheck passes, and zero-warning lint passes on the two changed source files. Lint has no config that covers the new test file, so it wasn't linted. One thing to know: when the log write itself is what fails, the failure path tries it once more. The Codex agent does the same. No preview was made, because nothing visible changed. PR: #3849 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5 ProPR-Agent: claude/claude-opus-5-5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR adds Pi across agent registration, execution, model routing, output parsing, and cost accounting. No merge-blocking defect is established by the supplied code. It is merge-ready within the reviewed scope, conditional on the remaining checks passing. ✅ Provider costs survive conversion — The authoritative cost field reaches metrics through task, PR-follow-up, and failed-result conversions, including zero-cost responses. ✅ Provider failures are recognized — Success requires a settled, unaborted run and rejects an assistant error even when Pi exits with code zero. ✅ Secret transport avoids argv — Provider keys and scoped GitHub credentials use Docker environment forwarding; configured GitHub credentials and reserved Pi variables are filtered. This was a static review of the supplied diff and surrounding excerpts. No commands were run. Current checks report 30 passed, four pending, and ten neutral/skipped; container execution remains unverified here. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S3: 🟢 Report model-suffix reasoning consistently
S4: 🟢 Exercise host-path mounting in DockerAdd a smoke test covering both implementation and analysis using existing host credentials in a containerized deployment. In ScoreThe implementation is cohesive and has targeted parser, invocation, watchdog, and post-execution failure coverage. No verified blocker remains, although the assessment is static and four current-head checks are still pending. Score: 8/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
AI Implementation Summary
Closes #3832
Branch:
3832/claude-opus-5-5-pi-agent-type-and-piagent-20261127-1622-0nlCommits: ✅ Changes committed (989cf03)
AI Processing Completed
Execution Details:
Summary:
I've registered
pias a full agent type, and implementation tasks and PR follow-ups now run through Pi in JSON mode with the whole trace saved as execution events. The new tests pass (23 of 23). So do the existing suites I picked that touch agent types, models, reasoning levels, metrics, the watchdog and the CLI, plus the propr-ui Settings/config tests. Typecheck passes for every package and lint passes for core and rootsrc/. I did not run a real containerised Pi task: there's no Docker here, so the full in-image run hasn't happened yet.Agent type.
piis now in the shared and core type lists,createAgentFromConfig, the default config path (~/.pi/agent, overridable withPI_CONFIG_PATH/HOST_PI_DIR), the in-container path, the health-check models, the PR template's agent name, and the CLI and UI types. Now thatpiis a real agent type, I removed the temporary image-onlypientry that #3839 added;AgentCliTypeis now just an alias for the agent type.Invocation. Each run is
pi -p --mode json --model <provider/id> [--thinking <level>] --session-dir /tmp/propr-pi-home/agent/sessions --no-approve, with the prompt on stdin.lowthroughmaxpass straight through.ultraandultracoderun atmax. Unset orautoleaves the model's own default.node.read,grep,find,lswhen the caller allows read-only inspection.Model IDs. These use the form
pi-<provider>/<model>, with an optional:<thinking>suffix. The defaults are Opus 5.5, Sonnet 5.5, GPT-6.2 Astra, Gemini 4 Argon and Devstral 2 via OpenRouter. PR titles, aliases (e.g.llm-pi-devstral2) and pricing resolve to the underlying model. The startup config migration no longer drops Pi models that aren't in the catalog, and doesn't re-add default models an operator has removed.Parser. It reads the session id, summary, success rule, per-response token sums and provider cost exactly as the issue specifies. Each tool call gets exactly one result event: Pi reports a result in both
tool_execution_endand atoolResultmessage, andturn_endrepeats it, so duplicates are skipped. The failedcat missing.txtcall is recorded withis_error: true.Things that behave differently from what you might assume:
stopReason: "error"and exit code 0. The success rule catches this, and there's a test built from that output.providerCostUsdfield. It's passed through the result converters intorecordLLMMetrics, which uses it before pricing. It is only set when every response saystotalFromProvider, so other agents are unaffected.Watchdog. Pi's
toolCallblocks,tool_execution_start/_end,toolResultmessages andturn_endresults are now tracked as tool calls. A long-running tool is held to the longer tool threshold instead of being treated as a stall.Tests and docs. The fixture is at
test/fixtures/pi/pi-1.6.1-json-tool-task.jsonland the tests are intest/piAgent.test.ts. I updated two existing tests for the new type: a missingpientry inagentDefaultConfigPathsand an expected error message inapiOpenCodeRoutes.docs/docs/features/agents-and-models.mdnow has a Pi row and a short Pi section.Not done:
HOST_PI_DIR(orchestrator,initStack,checkCommands).No preview was made: the only visible change is that new "Pi" option in the type selector.
Review digest
Risk-tiered paths
packages/api/services/agentHealthCheck.ts(+1/−0)packages/cli/src/api/agents.ts(+6/−4)packages/core/src/agents/constants.ts(+6/−11)packages/core/src/agents/createAgentFromConfig.ts(+3/−0)packages/core/src/agents/impl/PiAgent.ts(added, +226/−0)packages/core/src/agents/impl/piModelIds.ts(added, +69/−0)packages/core/src/agents/impl/utils/failedAgentExecution.ts(+1/−0)packages/core/src/agents/impl/utils/piDockerArgsBuilder.ts(added, +121/−0)packages/core/src/agents/impl/utils/piExecutionResult.ts(added, +53/−0)packages/core/src/agents/impl/utils/piOutputParser.ts(added, +318/−0)packages/core/src/agents/types.ts(+4/−1)packages/core/src/claude/claudeService.ts(+2/−0)packages/core/src/claude/docker/agentOutputActivity.ts(+40/−2)packages/core/src/config/agentConfigPaths.ts(+6/−3)packages/core/src/config/configManager.ts(+2/−0)packages/core/src/config/configManagerAgentMigrations.ts(+7/−2)packages/core/src/config/configManagerReasoning.ts(+15/−0)packages/core/src/config/modelAliases.ts(+21/−2)packages/core/src/config/modelDefinitions.ts(+1/−0)packages/core/src/config/modelLabelResolution.ts(+1/−1)packages/core/src/index.ts(+5/−1)packages/core/src/utils/llmMetrics.ts(+3/−3)packages/core/src/utils/llmMetrics.types.ts(+2/−0)packages/shared/src/index.ts(+2/−0)packages/shared/src/modelDefinitions.ts(+27/−4)packages/shared/src/prTemplate.ts(+1/−1)packages/shared/src/reasoningLevels.ts(+10/−0)propr-ui/src/api/proprTypes.ts(+2/−2)src/daemon/managedDiagnostics.ts(+3/−1)src/jobs/errorHandlers.ts(+2/−1)src/jobs/issueJob/agent.ts(+3/−1)src/jobs/prCommentJobUtils.ts(+2/−1)src/jobs/prFileUtils.ts(+1/−0)docs/docs/features/agents-and-models.md(+8/−1)test/agentDefaultConfigPaths.test.ts(+1/−0)test/apiOpenCodeRoutes.test.ts(+1/−1)test/fixtures/pi/pi-1.6.1-json-tool-task.jsonl(added, +16/−0)test/piAgent.test.ts(added, +292/−0)Diff size: 38 files changed, +1,284/−43 lines
View task for the run's logs and conversation.
This PR was created automatically by ProPR after processing issue #3832.
💡 Need changes?
Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!