Skip to content

Commit 8a85bc3

Browse files
committed
docs: document infinite sessions feature in all SDKs
- Add InfiniteSessionConfig documentation to SessionConfig options - Document workspacePath property on CopilotSession - Add Infinite Sessions section with examples for each SDK - Document compaction events
1 parent d10701b commit 8a85bc3

File tree

4 files changed

+161
-2
lines changed

4 files changed

+161
-2
lines changed

dotnet/README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ Create a new conversation session.
9797
- `ExcludedTools` - List of tool names to disable
9898
- `Provider` - Custom API provider configuration (BYOK)
9999
- `Streaming` - Enable streaming of response chunks (default: false)
100+
- `InfiniteSessions` - Configure automatic context compaction (see below)
100101

101102
##### `ResumeSessionAsync(string sessionId, ResumeSessionConfig? config = null): Task<CopilotSession>`
102103

103-
Resume an existing session.
104+
Resume an existing session. Returns the session with `WorkspacePath` populated if infinite sessions were enabled.
104105

105106
##### `PingAsync(string? message = null): Task<PingResponse>`
106107

@@ -127,6 +128,7 @@ Represents a single conversation session.
127128
#### Properties
128129

129130
- `SessionId` - The unique identifier for this session
131+
- `WorkspacePath` - Path to the session workspace directory when infinite sessions are enabled. Contains `checkpoints/`, `plan.md`, and `files/` subdirectories. Null if infinite sessions are disabled.
130132

131133
#### Methods
132134

@@ -256,6 +258,46 @@ When `Streaming = true`:
256258

257259
Note: `AssistantMessageEvent` and `AssistantReasoningEvent` (final events) are always sent regardless of streaming setting.
258260

261+
## Infinite Sessions
262+
263+
By default, sessions use **infinite sessions** which automatically manage context window limits through background compaction and persist state to a workspace directory.
264+
265+
```csharp
266+
// Default: infinite sessions enabled with default thresholds
267+
var session = await client.CreateSessionAsync(new SessionConfig
268+
{
269+
Model = "gpt-5"
270+
});
271+
272+
// Access the workspace path for checkpoints and files
273+
Console.WriteLine(session.WorkspacePath);
274+
// => ~/.copilot/session-state/{sessionId}/
275+
276+
// Custom thresholds
277+
var session = await client.CreateSessionAsync(new SessionConfig
278+
{
279+
Model = "gpt-5",
280+
InfiniteSessions = new InfiniteSessionConfig
281+
{
282+
Enabled = true,
283+
BackgroundCompactionThreshold = 0.80, // Start compacting at 80% context usage
284+
BufferExhaustionThreshold = 0.95 // Block at 95% until compaction completes
285+
}
286+
});
287+
288+
// Disable infinite sessions
289+
var session = await client.CreateSessionAsync(new SessionConfig
290+
{
291+
Model = "gpt-5",
292+
InfiniteSessions = new InfiniteSessionConfig { Enabled = false }
293+
});
294+
```
295+
296+
When enabled, sessions emit compaction events:
297+
298+
- `SessionCompactionStartEvent` - Background compaction started
299+
- `SessionCompactionCompleteEvent` - Compaction finished (includes token counts)
300+
259301
## Advanced Usage
260302

261303
### Manual Server Control

go/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,44 @@ When `Streaming: true`:
263263

264264
Note: `assistant.message` and `assistant.reasoning` (final events) are always sent regardless of streaming setting.
265265

266+
## Infinite Sessions
267+
268+
By default, sessions use **infinite sessions** which automatically manage context window limits through background compaction and persist state to a workspace directory.
269+
270+
```go
271+
// Default: infinite sessions enabled with default thresholds
272+
session, _ := client.CreateSession(&copilot.SessionConfig{
273+
Model: "gpt-5",
274+
})
275+
276+
// Access the workspace path for checkpoints and files
277+
fmt.Println(session.WorkspacePath())
278+
// => ~/.copilot/session-state/{sessionId}/
279+
280+
// Custom thresholds
281+
session, _ := client.CreateSession(&copilot.SessionConfig{
282+
Model: "gpt-5",
283+
InfiniteSessions: &copilot.InfiniteSessionConfig{
284+
Enabled: copilot.Bool(true),
285+
BackgroundCompactionThreshold: Float64(0.80), // Start compacting at 80% context usage
286+
BufferExhaustionThreshold: Float64(0.95), // Block at 95% until compaction completes
287+
},
288+
})
289+
290+
// Disable infinite sessions
291+
session, _ := client.CreateSession(&copilot.SessionConfig{
292+
Model: "gpt-5",
293+
InfiniteSessions: &copilot.InfiniteSessionConfig{
294+
Enabled: copilot.Bool(false),
295+
},
296+
})
297+
```
298+
299+
When enabled, sessions emit compaction events:
300+
301+
- `session.compaction_start` - Background compaction started
302+
- `session.compaction_complete` - Compaction finished (includes token counts)
303+
266304
## Transport Modes
267305

268306
### stdio (Default)

nodejs/README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ Create a new conversation session.
8989
- `model?: string` - Model to use ("gpt-5", "claude-sonnet-4.5", etc.)
9090
- `tools?: Tool[]` - Custom tools exposed to the CLI
9191
- `systemMessage?: SystemMessageConfig` - System message customization (see below)
92+
- `infiniteSessions?: InfiniteSessionConfig` - Configure automatic context compaction (see below)
9293

9394
##### `resumeSession(sessionId: string, config?: ResumeSessionConfig): Promise<CopilotSession>`
9495

95-
Resume an existing session.
96+
Resume an existing session. Returns the session with `workspacePath` populated if infinite sessions were enabled.
9697

9798
##### `ping(message?: string): Promise<{ message: string; timestamp: number }>`
9899

@@ -116,6 +117,16 @@ Delete a session and its data from disk.
116117

117118
Represents a single conversation session.
118119

120+
#### Properties
121+
122+
##### `sessionId: string`
123+
124+
The unique identifier for this session.
125+
126+
##### `workspacePath?: string`
127+
128+
Path to the session workspace directory when infinite sessions are enabled. Contains `checkpoints/`, `plan.md`, and `files/` subdirectories. Undefined if infinite sessions are disabled.
129+
119130
#### Methods
120131

121132
##### `send(options: MessageOptions): Promise<string>`
@@ -305,6 +316,40 @@ const session = await client.createSession({
305316
});
306317
```
307318

319+
### Infinite Sessions
320+
321+
By default, sessions use **infinite sessions** which automatically manage context window limits through background compaction and persist state to a workspace directory.
322+
323+
```typescript
324+
// Default: infinite sessions enabled with default thresholds
325+
const session = await client.createSession({ model: "gpt-5" });
326+
327+
// Access the workspace path for checkpoints and files
328+
console.log(session.workspacePath);
329+
// => ~/.copilot/session-state/{sessionId}/
330+
331+
// Custom thresholds
332+
const session = await client.createSession({
333+
model: "gpt-5",
334+
infiniteSessions: {
335+
enabled: true,
336+
backgroundCompactionThreshold: 0.80, // Start compacting at 80% context usage
337+
bufferExhaustionThreshold: 0.95, // Block at 95% until compaction completes
338+
},
339+
});
340+
341+
// Disable infinite sessions
342+
const session = await client.createSession({
343+
model: "gpt-5",
344+
infiniteSessions: { enabled: false },
345+
});
346+
```
347+
348+
When enabled, sessions emit compaction events:
349+
350+
- `session.compaction_start` - Background compaction started
351+
- `session.compaction_complete` - Compaction finished (includes token counts)
352+
308353
### Multiple Sessions
309354

310355
```typescript

python/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,40 @@ When `streaming=True`:
215215

216216
Note: `assistant.message` and `assistant.reasoning` (final events) are always sent regardless of streaming setting.
217217

218+
## Infinite Sessions
219+
220+
By default, sessions use **infinite sessions** which automatically manage context window limits through background compaction and persist state to a workspace directory.
221+
222+
```python
223+
# Default: infinite sessions enabled with default thresholds
224+
session = await client.create_session({"model": "gpt-5"})
225+
226+
# Access the workspace path for checkpoints and files
227+
print(session.workspace_path)
228+
# => ~/.copilot/session-state/{session_id}/
229+
230+
# Custom thresholds
231+
session = await client.create_session({
232+
"model": "gpt-5",
233+
"infinite_sessions": {
234+
"enabled": True,
235+
"background_compaction_threshold": 0.80, # Start compacting at 80% context usage
236+
"buffer_exhaustion_threshold": 0.95, # Block at 95% until compaction completes
237+
},
238+
})
239+
240+
# Disable infinite sessions
241+
session = await client.create_session({
242+
"model": "gpt-5",
243+
"infinite_sessions": {"enabled": False},
244+
})
245+
```
246+
247+
When enabled, sessions emit compaction events:
248+
249+
- `session.compaction_start` - Background compaction started
250+
- `session.compaction_complete` - Compaction finished (includes token counts)
251+
218252
## Requirements
219253

220254
- Python 3.8+

0 commit comments

Comments
 (0)