Repository navigation
[3831 by Claude Opus 5.5] Pi: install the CLI in the agent image with a disposable runtime and safe credential handling - #3839
Conversation
Pi 1.6.1 is now in the agent image, with its own entrypoint and the credential write-back helper. I couldn't build the image here because there's no Docker in this container, so the image build and the new smoke checks haven't run. Their first real run will be CI. Tested: - I installed Pi 1.6.1 from npm and ran the Dockerfile's `pi --version` / `pi --help` flag check against it; it passes and catches a missing flag. - Through a local logging proxy, Pi sent its provider traffic via `HTTPS_PROXY` and contacted only the provider host (`api.anthropic.com`, `openrouter.ai`). It made no `pi.dev` calls in `-p` mode. - The new test file `test/piCredentials.test.ts` (23 cases) passes. It covers the credential helper and runs the entrypoint as a non-root user with a stand-in `pi`. - The related suites pass, and typecheck (core, API, root) and core lint are clean. - One test fails, and it was already failing: `thirdPartyNotices` "committed notice carries the date…". The `Generated:` date in `THIRD_PARTY_LICENSES.md` doesn't match the last `package-lock.json` commit; I didn't change either. Decision for you: the issue asks for `pi: '1.6.1'` in `AGENT_DEFAULT_VERSIONS`, but `pi` only becomes an agent type in #3832. Adding it to `AgentType` now would ripple through the UI and about 40 typed lookup tables. Instead I added an `AgentCliType` (the agent types plus `pi`) and used it only for the image version tables, labels, build args, egress lists and the entrypoint map. When #3832 adds `pi` as an agent type the extra entry deduplicates itself and nothing else needs undoing. The catch: if you'd rather `pi` became a full agent type in this change, that pulls a chunk of #3832 forward. What's in place: - Image: a `pi-cli` stage installs `@earendil-works/pi-coding-agent@${PI_CLI_VERSION}` (default 1.6.1), checks `pi --version` and that `pi --help` lists the eight required flags, and puts `pi` on PATH. The final image gets a `dev.propr.agent.pi.version` label. `scripts/build-images.sh` has the matching `PI_CLI_VERSION`. Both content-hash lists and the app image's build context include the new files. Npm version lookup works for the scoped package. - Entrypoint (`scripts/pi-entrypoint.sh`), dispatched from `agent-entrypoint.sh`: - Each run starts with a fresh `/tmp/propr-pi-home/agent` as `PI_CODING_AGENT_DIR`, with sessions under it. - It copies only `auth.json`, `settings.json`, `models.json`, `AGENTS.md`, `SYSTEM.md` and `APPEND_SYSTEM.md` from `PROPR_PI_SOURCE_DIR`. Host `sessions/`, `extensions/` and `mcp.json` are never copied; ProPR can supply its own `mcp.json` through `PROPR_PI_MCP_CONFIG`. - It sets `PI_SKIP_VERSION_CHECK=1` and `PI_TELEMETRY=0`. It also sets `PI_OFFLINE=1`, which the issue didn't ask for. It stops Pi's startup model-catalog fetch from `pi.dev`, and the value can be overridden. - Every Pi or helper call (seed, version probe, the task, sync) goes through `su-exec node`. The task's exit status is passed through. - Provider API-key env vars pass through unchanged. - Credentials (`scripts/pi-credentials.py`): `seed` saves an owner-only snapshot of the imported `auth.json` before Pi touches it. `sync` writes refreshed OAuth entries back one provider at a time, only if the host entry still equals the snapshot. It never rewrites API-key entries, never adds or removes providers, and writes nothing if no OAuth entry changed. The write is atomic: temp file opened with `O_CREAT|O_EXCL, 0o600`, original mode kept. It also takes Pi's own `auth.json.lock` (same format as Pi's locking library), so it can't interleave with a host Pi refresh; stale locks are taken over. - Egress: Pi's allowlist covers Anthropic, OpenAI and ChatGPT sign-in, OpenRouter, Gemini and GitHub Copilot, including their token-refresh hosts. `pi.dev` and `radius.pi.dev` are excluded, and Pi is marked as proxy-compatible. - Smoke tests: `scripts/smoke-test-images.sh` runs `pi --version` through the entrypoint and compares it with the image label. It also starts the entrypoint as `--user 0:0` with a mounted source dir and fails if anything under `/tmp/propr-pi-home` isn't owned by `node`. The preview-image smoke test covers Pi the same way. - Other: third-party notices list the new package as MIT, and `agent-runtime.md` has a short Pi section. I updated the existing test fixtures that list image labels, and added a Pi case to the provider-egress test. There's nothing visible to capture, so I made no preview. 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: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR adds Pi to the unified image, version metadata, entrypoint dispatch, and restricted networking without prematurely exposing it as a selectable agent. It needs changes before merge because two filesystem cases can damage or misdirect host credential state. ✅ Consistent image integration — Pi participates in build arguments, image labels, version hashes, managed-image verification, and build-context file lists. ✅ Selective credential updates — The helper compares OAuth entries against their seeded values and preserves concurrent host changes and API-key entries. This review used static analysis of the supplied code only; no commands were run. Current checks show 19 passed, five pending, and no failures. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 Reject runtime paths that contain host credentials
F2: 🔴 Preserve symlinked credential destinations
SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Exercise termination cleanupAdd an entrypoint regression test that refreshes credentials during a long-running task and then terminates the container. The current tests cover normal and nonzero command exits, while synchronization occurs only after the foreground command returns. This optional test would establish signal-forwarding and credential-cleanup behavior. ScoreThe image integration and ordinary credential-update paths are well covered, but host-state deletion and symlink replacement require localized corrections. Pending checks are not themselves blockers. 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 dc9ba04
Summary of ChangesI fixed both findings, F1 and F2. F1: a runtime home could delete the host Pi dir (
F2: write-back replaced a symlinked
The other place this could matter is Review digestRisk-tiered paths
Diff size: 3 files changed, +68/−3 lines 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
I fixed both findings, F1 and F2. `test/piCredentials.test.ts` now passes in full (26 of 26). I also ran the new tests against the old scripts: the two regressions below fail there, so they do catch the original bugs. **F1: a runtime home could delete the host Pi dir** (`scripts/pi-entrypoint.sh`) - Before anything is deleted or chowned, the entrypoint now resolves both `PROPR_PI_RUNTIME_HOME` and `PROPR_PI_SOURCE_DIR` to real paths, following symlinks and `..`. - It then refuses with exit 64 if either path is inside the other. Before, it only caught a runtime home inside the source dir, not one that contains it. - It also refuses a runtime home that resolves to `/`. The old check only caught the literal value `/`, so something like `/tmp/..` would have got through. - New tests: a runtime home that contains the source dir, given as the parent dir (the `/home/node/.pi` case), as `agent/..`, and as a symlink to the parent. Each one exits 64 and leaves the host `auth.json` and `sessions/` untouched. A runtime home equal to the source dir is also refused. **F2: write-back replaced a symlinked `auth.json`** (`scripts/pi-credentials.py`) - `sync` now resolves the host `auth.json` path once. It uses that real file for the lock, the read, the file mode and the atomic replace. The temp file is created next to the real file, the target gets the new credentials, and the symlink stays in place. - This matches Pi's own lock, which is also taken on the real file. - New test: with `auth.json` as a symlink to a mode-0640 file elsewhere, after a refresh the link still exists and points to the same file. That file holds the refreshed entry, keeps mode 0640, and has no temp or lock files left next to it. The other place this could matter is `seed`, which writes the snapshot. It deletes the snapshot path first, so it never writes through a link and needed no change. PR: #3839 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 to the unified image, version management, entrypoint dispatch, and restricted networking while keeping selectable agent types unchanged. It needs a localized lifecycle fix before merge. ✅ Consistent image integration — Pi participates in build arguments, image labels, content hashes, managed-image verification, and the application’s bundled build context. ✅ Selective credential updates — Write-back preserves unrelated providers and skips entries changed on the host since import. Tests cover these cases and symlinked credential files. The supplied current-head status shows 22 passed checks, two pending, and no failures. This review used static analysis only, as requested. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F3: 🔴 Forward termination and preserve credential cleanup
SuggestionsThese are optional follow-ups and are not sent to S2: 🟢 Exercise actual lock interoperabilityThe credential tests simulate Pi’s lock using Python-created directories. A follow-up test against the pinned Pi implementation would help detect differences in lock acquisition, stale-lock handling, and release behavior during future upgrades. This is additional interoperability coverage, not a separately demonstrated blocker. ScoreThe image integration and credential merge logic are well covered, but interrupted execution can bypass credential persistence and graceful shutdown. The correction is localized; current checks report no failures. 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 b5bcc09
Summary of ChangesI fixed F3: stopping a Pi container mid-task now passes the signal on to Pi, waits for Pi to exit, and still writes refreshed OAuth credentials back to the host. All 28 tests in What changed in
Tests and docs:
Separate finding (not changed): in an interactive I didn't change tini to signal the whole process group ( Review digestRisk-tiered paths
Diff size: 3 files changed, +118/−12 lines 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
I fixed F3: stopping a Pi container mid-task now passes the signal on to Pi, waits for Pi to exit, and still writes refreshed OAuth credentials back to the host. All 28 tests in `test/piCredentials.test.ts` pass, including the two new ones. Against the old entrypoint, both new tests fail. I couldn't run the root code path (starting as root and dropping to `node` via `su-exec`) here, because there's no root or Docker in this container; CI's image smoke test is its first real run. **What changed in `scripts/pi-entrypoint.sh`:** - **Signal forwarding:** Pi now runs as a background child instead of in the foreground. Handlers for `SIGTERM`, `SIGINT` and `SIGHUP` pass the signal to Pi. The shell keeps waiting until Pi has actually exited, then runs the credential sync once. - **Exit status:** the container exits with Pi's status, which is 143 after `docker stop` if Pi doesn't handle the signal. If Pi exits cleanly after being told to stop, the entrypoint reports `128 + signal` rather than 0. A signal that arrives during the sync waits until the sync finishes. - **Three problems I hit and fixed while testing:** - The background job was a bash subshell running a helper function, so signals reached the subshell and left Pi orphaned. A new `exec_as_node` helper makes the task's PID Pi itself. - Bash without job control makes background commands ignore `SIGINT` and `SIGQUIT`. The task now starts with `env --default-signal=INT,QUIT` to undo that; Debian bookworm's coreutils 9.1 supports the flag. - Bash also points a background command's stdin at `/dev/null`, so the prompt on stdin is now passed through explicitly. **Tests and docs:** - New tests for `SIGTERM` and `SIGINT`. A stand-in Pi refreshes the Anthropic token and keeps running; the test then signals the entrypoint the way tini would. They check: - the exit status is 143 or 130. - Pi was stopped, not left running. - the host `auth.json` holds the refreshed entry and nothing else changed. - The existing run test now also checks that the prompt on stdin reaches Pi. - I updated the existing check that every Pi call drops to `node` so it covers `exec_as_node`. - The Pi section of `agent-runtime.md` now has one sentence on the shutdown behaviour. **Separate finding (not changed):** in an interactive `docker run -it`, Ctrl-C reaches Pi from the terminal and again from the entrypoint, so Pi gets `SIGINT` twice. ProPR runs Pi with `-p` and no terminal, so this only matters for manual interactive use. I didn't change tini to signal the whole process group (`tini -g`). That would affect every agent image, which is beyond this finding. PR: #3839 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 to the unified agent image, version matrix, entrypoint dispatch, and restricted-network configuration while keeping selectable agent integration separate. The implementation appears merge-ready within scope, conditional on the remaining check completing successfully. ✅ Consistent image integration — Pi participates in build arguments, image labels, version hashes, managed-image verification, and both build-context file lists. ✅ Careful credential write-back — Sync compares individual OAuth entries against the imported snapshot, preserves concurrent host changes, and uses an atomic replacement under the credential lock. ✅ Execution lifecycle coverage — Tests cover stdin forwarding, exit-status preservation, signal forwarding, credential sync, and rejection of overlapping runtime/source directories. This assessment is based on static review of the supplied code; no commands were run. The authoritative checks report 24 passed, none failed, and one pending. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S3: 🟢 Test real lock interoperabilityThe credential tests exercise simulated lock holders, but do not directly exercise Pi’s locking library against S4: 🟢 Exercise root task executionThe new root smoke test checks ownership through ScoreThe implementation is coherent and well covered, with no verified merge blockers in the supplied diff. Final readiness remains conditional on the pending validation check. Score: 9/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
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
…or tasks, with full persisted execution events (#3849) * feat: add Pi agent type with JSON-mode runs and persisted events 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 * test: add pi to expected agent types in OpenCode CLI help test 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 * fix: keep Pi run results when post-run steps fail 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 --------- Co-authored-by: propr-dev[bot] <1316198+propr-dev[bot]@users.noreply.github.com>
AI Implementation Summary
Closes #3831
Branch:
3831/claude-opus-5-5-pi-install-the-cli-in-the-20261127-1443-62sCommits: ✅ Changes committed (0f5b94c)
AI Processing Completed
Execution Details:
Summary:
Pi 1.6.1 is now in the agent image, with its own entrypoint and the credential write-back helper. I couldn't build the image here because there's no Docker in this container, so the image build and the new smoke checks haven't run. Their first real run will be CI.
Tested:
pi --version/pi --helpflag check against it; it passes and catches a missing flag.HTTPS_PROXYand contacted only the provider host (api.anthropic.com,openrouter.ai). It made nopi.devcalls in-pmode.test/piCredentials.test.ts(23 cases) passes. It covers the credential helper and runs the entrypoint as a non-root user with a stand-inpi.thirdPartyNotices"committed notice carries the date…". TheGenerated:date inTHIRD_PARTY_LICENSES.mddoesn't match the lastpackage-lock.jsoncommit; I didn't change either.Decision for you: the issue asks for
pi: '1.6.1'inAGENT_DEFAULT_VERSIONS, butpionly becomes an agent type in #3832. Adding it toAgentTypenow would ripple through the UI and about 40 typed lookup tables. Instead I added anAgentCliType(the agent types pluspi) and used it only for the image version tables, labels, build args, egress lists and the entrypoint map. When #3832 addspias an agent type the extra entry deduplicates itself and nothing else needs undoing. The catch: if you'd ratherpibecame a full agent type in this change, that pulls a chunk of #3832 forward.What's in place:
pi-clistage installs@earendil-works/pi-coding-agent@${PI_CLI_VERSION}(default 1.6.1), checkspi --versionand thatpi --helplists the eight required flags, and putspion PATH. The final image gets adev.propr.agent.pi.versionlabel.scripts/build-images.shhas the matchingPI_CLI_VERSION. Both content-hash lists and the app image's build context include the new files. Npm version lookup works for the scoped package.scripts/pi-entrypoint.sh), dispatched fromagent-entrypoint.sh:/tmp/propr-pi-home/agentasPI_CODING_AGENT_DIR, with sessions under it.auth.json,settings.json,models.json,AGENTS.md,SYSTEM.mdandAPPEND_SYSTEM.mdfromPROPR_PI_SOURCE_DIR. Hostsessions/,extensions/andmcp.jsonare never copied; ProPR can supply its ownmcp.jsonthroughPROPR_PI_MCP_CONFIG.PI_SKIP_VERSION_CHECK=1andPI_TELEMETRY=0. It also setsPI_OFFLINE=1, which the issue didn't ask for. It stops Pi's startup model-catalog fetch frompi.dev, and the value can be overridden.su-exec node. The task's exit status is passed through.scripts/pi-credentials.py):seedsaves an owner-only snapshot of the importedauth.jsonbefore Pi touches it.syncwrites refreshed OAuth entries back one provider at a time, only if the host entry still equals the snapshot. It never rewrites API-key entries, never adds or removes providers, and writes nothing if no OAuth entry changed. The write is atomic: temp file opened withO_CREAT|O_EXCL, 0o600, original mode kept. It also takes Pi's ownauth.json.lock(same format as Pi's locking library), so it can't interleave with a host Pi refresh; stale locks are taken over.pi.devandradius.pi.devare excluded, and Pi is marked as proxy-compatible.scripts/smoke-test-images.shrunspi --versionthrough the entrypoint and compares it with the image label. It also starts the entrypoint as--user 0:0with a mounted source dir and fails if anything under/tmp/propr-pi-homeisn't owned bynode. The preview-image smoke test covers Pi the same way.agent-runtime.mdhas a short Pi section. I updated the existing test fixtures that list image labels, and added a Pi case to the provider-egress test.There's nothing visible to capture, so I made no preview.
Review digest
Risk-tiered paths
scripts/pi-credentials.py(added, +166/−0): auth-looking pathDockerfile.agent(+26/−0)docker/Dockerfile.app.prod(+2/−0)packages/core/src/agents/constants.ts(+11/−0)packages/core/src/agents/managedAgentImage.ts(+2/−2)packages/core/src/agents/managedAgentPin.ts(+4/−4)packages/core/src/agents/version/types.ts(+13/−9)packages/core/src/agents/version/versionService.ts(+11/−10)packages/core/src/claude/docker/dockerImageBuilder.ts(+2/−1)packages/core/src/claude/docker/repoSetupWrapper.ts(+8/−6)packages/core/src/index.ts(+2/−2)packages/core/src/network/egressAllowlist.ts(+20/−5)packages/core/src/network/egressExecution.ts(+4/−4)scripts/agent-entrypoint.sh(+4/−3)scripts/build-images.sh(+6/−1)scripts/generate-notices.sh(+9/−2)scripts/pi-entrypoint.sh(added, +141/−0)scripts/preview-runtime-images.mjs(+1/−0)scripts/smoke-test-images.sh(+47/−2)scripts/smoke-test-preview-agent-image.sh(+4/−2)THIRD_PARTY_LICENSES.md(+6/−0)docs/docs/architecture/agent-runtime.md(+6/−0)packages/core/test/egressProxy.test.ts(+11/−1)test/agentBundleContentFiles.test.ts(+2/−1)test/agentDockerfileSupplyChain.test.ts(+1/−1)test/agentProviderEgress.test.ts(+7/−2)test/agentRegistryManagedAgentPin.test.ts(+1/−0)test/agentVersionManagement.test.ts(+56/−0)test/piCredentials.test.ts(added, +464/−0)test/previewAgentImage.test.mjs(+2/−1)test/previewCliPackage.test.mjs(+1/−1)test/releaseRolloutWorkflow.test.mjs(+1/−1)Diff size: 32 files changed, +1,041/−61 lines
View task for the run's logs and conversation.
This PR was created automatically by ProPR after processing issue #3831.
💡 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!