fix: pi extension banks a session id only once its file exists - #342
Merged
Merged
Conversation
pi names a session at startup but writes its JSONL only with the first
assistant message, and `pi --session <id>` exits 1 ("No session found
matching") on an id with no file. Banking at session_start left a dead id
for any session quit before its first reply, or a /new a reboot interrupted.
Bank when the file exists, retrying at tool_call and agent_settled.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XDp19dXj5ZKDEAMt65uRES
Owner
Author
|
Gate on Fails without the fix: with the base |
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.
Refs #214. Found while reviewing #338.
Problem
pi picks a session id at startup, but it only writes the session file when the first assistant message arrives. The presence extension banked the id at
session_start, before that file existed.pi --session <id>exits 1 withNo session found matching '<id>'when an id has no file. So the banked id was dead whenever:/newbefore its first reply. The dead id replaced the id of the conversation before it, so that conversation could no longer be resumed.Locally the ensure and the pane notice the resume dying and fall back to a fresh launch. That fallback costs an extra launch and a
resume-deadentry in the dial log, and it can't recover the conversation the dead id replaced.Fix
bank()now writes the id only oncegetSessionFile()exists on disk. It retries attool_callandagent_settled, the first points where pi has saved an assistant message. A session that already has a file, such as a resumed one, still banks atsession_start.Verified against pi 0.85.1
Tested with the real
pibinary, a fakezmxshim, and the rendered extension:--sessionexits 1A new test,
anIDIsBankedOnlyOnceItsSessionFileExists, checks that the file-existence check is in place and that both retry handlers callbank().🤖 Generated with Claude Code