fix: give the Pi runner a session identity, so continuity actually happens - #80
Merged
Merged
Conversation
…ppens PersistSession only omitted --no-session, which governs whether pi writes the transcript. Reading it back is a different flag — so an agent configured for continuity saved every conversation and remembered none of them: a two-prompt proof returned the first answer and then "No token was previously requested to be remembered", which is what a fresh session says. PiRunnerConfig.SessionID now passes pi's --session-id, creating the session on first use and continuing it thereafter. --session-id rather than --continue deliberately: it creates the session when it is missing, so a brand-new agent's first prompt behaves exactly like its thousandth, where --continue would be resuming nothing. Left empty for a task-routed agent, whose runs are unrelated tasks that must not be joined into one identity.
bborbe
marked this pull request as ready for review
September 26, 2026 22:11
Contributor
There was a problem hiding this comment.
CHANGELOG has ## Unreleased with a fix: prefix — standard convention. All three concerns from the plan are addressed. No issues found.
Summary
The fix adds SessionID to PiRunnerConfig and passes --session-id to the pi CLI when set. The bug: PersistSession=true only omitted --no-session (writing control), but reading the session back requires --session-id. An agent with persistence but no session ID saved every conversation and remembered none.
Verification:
pi/pi-runner.go:108-110— correctly appends--session-idwhenSessionID != "", complementingPersistSessionpi/pi-runner-config.go:31-48—PersistSessiondocs correctly distinguish write vs read;SessionIDdocs correctly explain why--session-id(not--continue) and when to leave it emptypi/pi-runner_test.go:100-116— both cases tested: session ID present and absent
No issues found.
{
"verdict": "approve",
"summary": "Bugfix correctly adds the missing --session-id flag that makes session continuity work. PersistSession only controls writing the transcript; --session-id is the separate flag that allows reading it back. Two new specs cover both configured and unconfigured cases. Documentation clearly explains the relationship between the two flags.",
"comments": [],
"concerns_addressed": [
{
"concern": "correctness: PersistSession removed --no-session but that flag only controls writing; reading requires --session-id",
"disposition": "addressed",
"detail": "pi-runner.go:108-110 adds --session-id when SessionID != ''; pi-runner-config.go:31-48 documents the write/read distinction correctly"
},
{
"concern": "correctness: New SessionID field documentation must correctly distinguish --no-session from --session-id",
"disposition": "addressed",
"detail": "pi-runner-config.go:31-48 explains PersistSession controls writing and SessionID controls reading; explains why --session-id (not --continue)"
},
{
"concern": "tests: Two new specs added — verify both exercise buildCommand fully",
"disposition": "addressed",
"detail": "pi-runner_test.go:100-116 tests --session-id passed when configured and omitted when not, both via the buildCommand path using the shim"
}
]
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The defect
PersistSessionomitted--no-sessionand nothing else. From pi's own--help:--no-sessiongoverns whether pi writes the transcript. Reading it back is a different flag. So an agent configured for continuity saved every conversation and remembered none of them — observed live:ACK{"status":"failed","message":"No token was previously requested to be remembered"}which is precisely what a fresh session says.
The fix
PiRunnerConfig.SessionIDpasses pi's--session-id.--session-idrather than--continuedeliberately: it creates the session when it is missing, so a brand-new agent's first prompt behaves exactly like its thousandth —--continuewould be resuming nothing on that first run.Left empty for a task-routed agent, whose runs are unrelated tasks that must not be joined into one identity.
Why it got through
The plan that scoped the work said:
The first clause is true; the second does not follow. Writing a session and continuing one are different flags, and nothing exercised the difference until a second prompt was sent to the same pod.
PersistSessionwas implemented, reviewed, and unit-tested on both sides without anyone asking whether the flag it removes is the flag that resumes.Tests
9 of 9specs in thepipackage, up from 7 — two new:--session-idis passed when configured, and no--session-idis passed when it is not.make precommitPASS —go test -raceall 10 packages, golangci-lint 0 issues, gosec clean, trivy 0 vulns / 0 secrets, osv clean.