Skip to content

Commit 6665c44

Browse files
josevalimbenbrandt
andauthored
RFD: Forking of existing sessions (#233)
* Add proposal for forking existing sessions * Add capabilities, update FAQ * Add ben as champion and add an example request * Add revision info * add to website --------- Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
1 parent 1dcd96a commit 6665c44

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

docs/docs.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@
9191
"rfds/about",
9292
{
9393
"group": "Draft",
94-
"pages": ["rfds/session-list", "rfds/session-config-options"]
94+
"pages": [
95+
"rfds/session-list",
96+
"rfds/session-config-options",
97+
"rfds/session-fork"
98+
]
9599
},
96100
{ "group": "Preview", "pages": [] },
97101
{ "group": "Completed", "pages": ["rfds/introduce-rfd-process"] }

docs/rfds/session-fork.mdx

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
title: "Forking of existing sessions"
3+
---
4+
5+
Author(s): [@josevalim](https://github.com/josevalim)
6+
Champion: [@benbrandt](https://github.com/benbrandt)
7+
8+
## Elevator pitch
9+
10+
> What are you proposing to change?
11+
12+
We propose adding the ability to "fork" a new session based on an existing one.
13+
This will allow us to use the current conversation as context to generate pull
14+
request descriptions, summaries, etc. without polluting the user history.
15+
16+
## Status quo
17+
18+
> How do things work today and what problems does this cause? Why would we change things?
19+
20+
Imagine we want to summarize the current conversation to use it in a future chat. If we send a message
21+
asking for the summary, it will become part of its context, affecting future user interactions.
22+
Therefore we want to be able to fork a session, issue additional messages, and then close the fork.
23+
24+
## What we propose to do about it
25+
26+
> What are you proposing to improve the situation?
27+
28+
To add a "session/fork" method.
29+
30+
## Shiny future
31+
32+
> How will things will play out once this feature exists?
33+
34+
We will be able to implement functionality that requires using the current chat
35+
without polluting its history, ranging from summaries to potentially subagents.
36+
37+
I can also see this feature being extended in the future to support an optional
38+
message ID, so the fork happens at a specific message, allowing clients to implement
39+
functionality like editing previous messages and similar.
40+
41+
## Implementation details and plan
42+
43+
> Tell me more about your implementation. What is your detailed implementation plan?
44+
45+
We propose to add a new "session/fork" method. Agents must declare this option is
46+
available by returning `session: { fork : {} }` in its capabilities. The object is reserved
47+
to declare future capabilities, such as forking from a specific message, a tool call, or similar.
48+
49+
Then the client would be able to request a fork of the current session:
50+
51+
```json
52+
{
53+
"jsonrpc": "2.0",
54+
"id": 1,
55+
"method": "session/fork",
56+
"params": {
57+
"sessionId": "sess_789xyz"
58+
}
59+
}
60+
```
61+
62+
And the agent would respond with optional data such as config options, the same as `session/load`.
63+
64+
A proof of concept is available here: https://github.com/zed-industries/claude-code-acp/pull/145
65+
66+
## Frequently asked questions
67+
68+
> What questions have arisen over the course of authoring this document or during subsequent discussions?
69+
70+
**Q: Should a new method be introduced or should "session/new" be expanded?**
71+
72+
They must be different because they will effectively require different options.
73+
For example, "session/new" has options such as capabilities and MCP which are not
74+
recommended to be set when forking, as the context being forked was built with other
75+
tools, and forking may accept a messageId for checkpoints.
76+
77+
### What alternative approaches did you consider, and why did you settle on this one?
78+
79+
None. This proposal is inspired by the abilities exposed in Claude Agent SDK. It must be validated against other agents too.
80+
81+
## Revision history
82+
83+
2025-11-17: Mentioned capabilities format, updated FAQ.
84+
2025-11-20: Added request format and updated capabilities format.

0 commit comments

Comments
 (0)