Skip to content

feat: deleting a session also deletes the agent's conversation - #91

Merged
deymosh merged 1 commit into
masterfrom
feat/delete-agent-session-files
Oct 8, 2026
Merged

deymosh merged 1 commit into
masterfrom
feat/delete-agent-session-files

Conversation

@deymosh

@deymosh deymosh commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Summary

Deleting a session from the phone now also deletes the agent's own copy of its conversation: Claude Code's transcript files, OpenCode's server-side session, and the DeepSeek Harness's session directory. Until now these piled up unseen and could still be resumed by hand.

  • Driver protocol: new delete-conversation {sessionId, agent, cwd, conversationId} request. The reply is ack, also when there was nothing to delete, or error. Documented in docs/PROTOCOL.md; the host's TS types are regenerated. The phone wire is unchanged.
  • Bridge: on close-session it sends one delete for each conversation the record points to: the current one, and one dropped as missing. Every such conversation was started by the bridge, since a session can only be created fresh. A delete the host could not take (it was down, or died with the request in flight) is held and sent again once the host is initialized. Deleting twice is harmless.
  • Host: lines are handled concurrently, so a delete waits for that session's end-session to finish and is refused while the session still runs.
  • Drivers:
    • Claude Code uses the SDK's deleteSession (transcript plus subagent transcripts). end() now also waits, at most 5 s, for the CLI to exit, so the CLI cannot write the transcript back after the delete.
    • OpenCode uses session.delete, which removes child sessions too; a 404 counts as already deleted.
    • DeepSeek Harness has no delete API, so the driver removes the session directory, plus every subagent session whose header names it as parent. It looks the conversation up by id across project directories instead of re-encoding the cwd.

Verification

  • cargo clippy --workspace --all-targets -D warnings and cargo test --workspace pass. So do the ignored driver-protocol spawn test and the bridge end-to-end test (-- --ignored, after a host build). The agent host's typecheck and tests pass (512).
  • Live, in the bridge container, through a second agent host built from this branch and speaking the driver protocol, each agent on deepseek-v4.1-flash. Each check ran one turn, then end-session and delete-conversation back to back, then a resume:
    • Claude Code: the .jsonl is gone; the resume reports "No conversation found".
    • OpenCode: the resume reports "Session not found". A separate probe confirmed that a subagent's child session returns 404 after its parent is deleted.
    • DeepSeek Harness: the session directory is gone; the resume starts a fresh conversation.

🤖 Generated with Claude Code

Deleting a session from the phone removed the bridge's record and
transcript but left the agent's own copy behind: Claude Code's transcript
files, OpenCode's server-side session, the DeepSeek Harness's session
directory. They piled up unseen and could still be resumed by hand.

A new driver-protocol request, delete-conversation, asks the agent host
to delete one conversation once its session has ended. The bridge sends
it on close-session for each conversation the record points to (the
current one, and one dropped as missing), all of them started by the
bridge itself. A request the host could not take (down, or it died with
the request in flight) is kept and sent once it is initialized again;
deleting twice is harmless.

The host handles lines concurrently, so the delete waits for that
session's end-session to finish and is refused while it still runs. Each
driver deletes what its agent keeps:
- Claude Code: the SDK's deleteSession (transcript plus subagent
  transcripts). Ending a session now also waits, bounded, for the CLI to
  exit, so it cannot write the transcript back after the delete.
- OpenCode: session.delete, which removes child sessions too; a 404 is
  already deleted.
- DeepSeek Harness: no API, so the session directory is removed, with
  every subagent session whose header names it as parent.

Verified live on the three agents: after the delete, resuming the
conversation finds nothing, and its files are gone.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@deymosh
deymosh merged commit e3ac59b into master Oct 8, 2026
6 checks passed
@deymosh
deymosh deleted the feat/delete-agent-session-files branch October 8, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant