feat(acp): implement session/load so BB threads resume with history - #1601
Closed
masked8knights wants to merge 2 commits into
Closed
feat(acp): implement session/load so BB threads resume with history#1601masked8knights wants to merge 2 commits into
masked8knights wants to merge 2 commits into
Conversation
BB's provider-acp host only restores a thread when the agent advertises loadSession and answers session/load; prime-agent announced loadSession: false, so every restarted BB chat fell back to session/new with blank in-agent history and the 'could not restore the previous session' warning. Advertise the capability and implement the handler: - session/new persists the ACP session id -> prime-agent JSONL session file mapping under the agent dir (acp-sessions/<id>.json). - session/load resolves the requested id to the saved transcript and switches the daemon connection back onto that session file, then admits the ACP session as usual, so prompts continue the restored conversation instead of starting fresh. - A missing mapping or file throws so the client falls back to a fresh session with its own warning rather than pretending history exists. Adds an end-to-end test that resumes a mapped session file across two connections (74/74 ACP tests pass).
|
Hi @masked8knights, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/PrimeIntellect-ai/prime-agent/blob/main/CONTRIBUTING.md for more details. |
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.
Supersedes #1600 (reopened from the rebased branch, based on current
main).Problem
When BB resumes a chat thread through its ACP provider, it calls
session/loadwith the thread's stored provider thread id. It only restores in-agent history when the agent advertisesloadSessionand answerssession/load.prime-agent's ACP mode advertised
loadSession: falseand had nosession/loadhandler, so every restarted BB conversation fell back tosession/newwith blank in-agent history, and BB showed:That's the "Prime Agent in BB keeps resetting / losing context" symptom.
Fix
loadSession: truein the ACPinitializeresponse.session/newpersists the ACP session id → prime-agent JSONL session file mapping under the agent dir (<agentDir>/acp-sessions/<id>.json).session/loadresolves the requested id to the saved transcript, switches the daemon connection back onto that session file, then admits the ACP session as usual — so subsequent prompts continue the restored conversation instead of starting fresh.session/newandsession/load.Verification
acp-mode,acp-features,acp-stop-reason,acp-events).Note
Implement ACP
session/loadto resume BB threads with persisted session historysession/loadrequest handler that resolves an ACP session id to a saved JSONL session file and switches the underlying connection to that file, restoring prior conversation history.session/new, the agent now writes an on-disk mapping (ACP session id → session file) underacp-sessions/in the agent directory, using atomic rename with0700permissions.initializenow advertisesagentCapabilities.loadSession = true.admitAcpSessionhelper used by bothsession/newandsession/load.session/loadfails if no mapping file exists on disk for the given sessionId; mapping persistence/lookup errors are swallowed, so a missing or corrupt mapping results in a load failure rather than a crash. Reviewers should checkresolveAcpSessionFilein acp-mode.ts and thePRIME_AGENT_CODING_AGENT_DIRfallback inacpSessionLinkDir.Macroscope summarized 9a338b4.