Repository navigation
[3836 by Claude Opus 5.5] Pi: goal support with session resume - #3859
Conversation
Goals can now run on Pi. A goal keeps a single Pi session across all its runs, and every later run reopens that session file, so the conversation carries through checkpoints, pauses, corrections and model changes.
How it works
- Capability: `goalCapabilities` reports Pi as goal-capable with `launch: 'goal-prompt'`, `resume: 'whole-session'`, `runningInput: 'safe-boundary-resume'`. The probe runs `pi --help` offline with nothing mounted and requires the session flags (`-p`, `--mode`, `--session`, `--session-id`, `--session-dir`, `--no-session`). `PiAgent.goalCapable` is now `true`.
- Where sessions live: each goal gets its own directory at `/tmp/git-processor/pi-goal-sessions/<goal-id>` (override with `PI_GOAL_SESSIONS_PATH`), outside Pi's disposable home. It's created at 0700 and mounted into the run.
- Owner-only: `scripts/pi-entrypoint.sh` chowns the mounted directory to `node` and sets it and its files to owner-only before Pi starts and again after it exits, including after a stop. Without this, Pi's session files come out world-readable (0644).
- New goal: the first run uses `--session-id <uuid>`, an ID ProPR assigns. The ID is saved as soon as the stream shows Pi has written the prompt to the session file. A run stopped before that saves nothing, so the next attempt starts fresh instead of resuming an empty session. To read that moment from the stream I added a small `sessionIdFromLine` option to the shared docker executor.
- Resume: later runs use `--session <exact file>`. If you point Pi 1.6.1 at a file that doesn't exist, it quietly starts an empty session there. So the worker checks the file exists first and fails the goal with a clear error if it's gone.
- Boundaries: checkpoints, model changes, pause and input go through the existing whole-session path in `processGoalJob.ts`. Goal input is sent to Pi unchanged, and direct goals protect the `.git` metadata.
- Environment: Pi now passes the per-run environment (goal mode, launch strategy, admission parent and its key) into the container by variable name. Before this, Pi dropped it; this applies to task runs too.
- Cleanup: deleting a goal removes its session directory. A finished goal keeps it so it can be continued.
- RPC mode (`--mode rpc` live steering) is not implemented; I documented it as a follow-up in `docs/docs/features/goals.md`.
The docs are also updated in `agents-and-models.md` and `architecture/agent-runtime.md`.
Testing
- New `test/piGoalSession.test.ts` (16 tests) covers the capability probe against the real Pi 1.6.1 help output, session store permissions, `--session-id` vs `--session` args, and the missing-file failure. It also covers a run that resumes and keeps the earlier conversation, and a resume after a checkpoint that delivers the checkpoint feedback into the same session.
- Two entrypoint tests in `test/piCredentials.test.ts` cover the owner-only permissions and refusing unsafe or missing directories.
- Separately, I ran the real Pi 1.6.1 binary through the real entrypoint against a mock model server. It created the session under the assigned ID and resumed it with the conversation intact ("seen 2 user messages"), with files at 0600 and directories at 0700.
- Typecheck passes for core, root and api, and lint is clean on the changed files. The existing Pi, goal, docker-executor and `processGoalJob` suites pass.
- The API goal route tests are only partly checked. `goalRoutes.test.ts` passes alone (it contains delete-route cases). Run together with `goalContinueRoute` and `goalCliRoutes`, it hit a 600s timeout with almost no output; that looks like the known hang at exit in `packages/api` tests, but I didn't confirm it.
There are no visual previews because nothing in the UI changes.
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 goals through persistent per-goal session storage and the existing whole-session execution path. The changes are focused and appear merge-ready within the supplied scope, conditional on the five pending checks completing successfully. ✅ Explicit session resume — Resumed runs select the saved session file and fail before launching Pi when that file is missing. ✅ Separated session storage — Goal sessions survive disposable-home cleanup, and the entrypoint restricts directory and file permissions before and after execution. ✅ Focused coverage — Added tests cover session identity, checkpoint feedback, model changes, missing files, environment forwarding, and preservation of ordinary task behavior. This was a static review of the supplied diff and context; no commands or tests were run. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Automate interrupted-session integration coverageThe new stand-in writes the session file itself before emitting the user’s ScoreThe implementation is cohesive and includes relevant regression coverage, with no verified merge blockers in the supplied code. Current checks report no failures, although five remain pending. Score: 8/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
AI Implementation Summary
Closes #3836
Branch:
3836/claude-opus-5-5-pi-goal-support-with-sess-20261127-2116-7kzCommits: ✅ Changes committed (1c117d7)
AI Processing Completed
Execution Details:
Summary:
Goals can now run on Pi. A goal keeps a single Pi session across all its runs, and every later run reopens that session file, so the conversation carries through checkpoints, pauses, corrections and model changes.
How it works
goalCapabilitiesreports Pi as goal-capable withlaunch: 'goal-prompt',resume: 'whole-session',runningInput: 'safe-boundary-resume'. The probe runspi --helpoffline with nothing mounted and requires the session flags (-p,--mode,--session,--session-id,--session-dir,--no-session).PiAgent.goalCapableis nowtrue./tmp/git-processor/pi-goal-sessions/<goal-id>(override withPI_GOAL_SESSIONS_PATH), outside Pi's disposable home. It's created at 0700 and mounted into the run.scripts/pi-entrypoint.shchowns the mounted directory tonodeand sets it and its files to owner-only before Pi starts and again after it exits, including after a stop. Without this, Pi's session files come out world-readable (0644).--session-id <uuid>, an ID ProPR assigns. The ID is saved as soon as the stream shows Pi has written the prompt to the session file. A run stopped before that saves nothing, so the next attempt starts fresh instead of resuming an empty session. To read that moment from the stream I added a smallsessionIdFromLineoption to the shared docker executor.--session <exact file>. If you point Pi 1.6.1 at a file that doesn't exist, it quietly starts an empty session there. So the worker checks the file exists first and fails the goal with a clear error if it's gone.processGoalJob.ts. Goal input is sent to Pi unchanged, and direct goals protect the.gitmetadata.--mode rpclive steering) is not implemented; I documented it as a follow-up indocs/docs/features/goals.md.The docs are also updated in
agents-and-models.mdandarchitecture/agent-runtime.md.Testing
test/piGoalSession.test.ts(16 tests) covers the capability probe against the real Pi 1.6.1 help output, session store permissions,--session-idvs--sessionargs, and the missing-file failure. It also covers a run that resumes and keeps the earlier conversation, and a resume after a checkpoint that delivers the checkpoint feedback into the same session.test/piCredentials.test.tscover the owner-only permissions and refusing unsafe or missing directories.processGoalJobsuites pass.goalRoutes.test.tspasses alone (it contains delete-route cases). Run together withgoalContinueRouteandgoalCliRoutes, it hit a 600s timeout with almost no output; that looks like the known hang at exit inpackages/apitests, but I didn't confirm it.There are no visual previews because nothing in the UI changes.
Review digest
Risk-tiered paths
packages/api/routes/goalRoutes.ts(+5/−0)packages/core/src/agents/goalCapabilities.ts(+24/−0)packages/core/src/agents/impl/PiAgent.ts(+52/−8)packages/core/src/agents/impl/utils/piDockerArgsBuilder.ts(+20/−7)packages/core/src/agents/impl/utils/piGoalSession.ts(added, +119/−0)packages/core/src/agents/types.ts(+5/−0)packages/core/src/claude/docker/dockerExecutor.ts(+3/−1)packages/core/src/claude/docker/dockerSessionOutput.ts(+3/−1)packages/core/src/goalExports.ts(+2/−0)scripts/pi-entrypoint.sh(+41/−0)src/jobs/processGoalJob.ts(+1/−0)docs/docs/architecture/agent-runtime.md(+4/−0)docs/docs/features/agents-and-models.md(+3/−3)docs/docs/features/goals.md(+13/−1)packages/core/test/fixtures/pi-help-1.6.1.txt(added, +198/−0)test/piCredentials.test.ts(+33/−0)test/piGoalSession.test.ts(added, +328/−0)Diff size: 17 files changed, +854/−21 lines
View task for the run's logs and conversation.
This PR was created automatically by ProPR after processing issue #3836.
💡 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!