Skip to content

Commit 06ff2ae

Browse files
friggeriCopilot
andauthored
Add missing options to ResumeSessionConfig for parity with create (#376)
* Add missing options to ResumeSessionConfig for parity with create - Add model, systemMessage, availableTools, excludedTools, configDir, and infiniteSessions to resume session config in all SDKs - Update client implementations to pass new options to server - Add "Resume Options" documentation section - Bump @github/copilot dependency to ^0.0.403 * Update python/copilot/client.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix lint --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent c7e0765 commit 06ff2ae

File tree

13 files changed

+262
-60
lines changed

13 files changed

+262
-60
lines changed

docs/guides/session-persistence.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,37 @@ var session = await client.ResumeSessionAsync("user-123-task-456");
164164
await session.SendAndWaitAsync(new MessageOptions { Prompt = "What did we discuss earlier?" });
165165
```
166166

167+
## Resume Options
168+
169+
When resuming a session, you can optionally reconfigure many settings. This is useful when you need to change the model, update tool configurations, or modify behavior.
170+
171+
| Option | Description |
172+
|--------|-------------|
173+
| `model` | Change the model for the resumed session |
174+
| `systemMessage` | Override or extend the system prompt |
175+
| `availableTools` | Restrict which tools are available |
176+
| `excludedTools` | Disable specific tools |
177+
| `provider` | Re-provide BYOK credentials (required for BYOK sessions) |
178+
| `reasoningEffort` | Adjust reasoning effort level |
179+
| `streaming` | Enable/disable streaming responses |
180+
| `workingDirectory` | Change the working directory |
181+
| `configDir` | Override configuration directory |
182+
| `mcpServers` | Configure MCP servers |
183+
| `customAgents` | Configure custom agents |
184+
| `skillDirectories` | Directories to load skills from |
185+
| `disabledSkills` | Skills to disable |
186+
| `infiniteSessions` | Configure infinite session behavior |
187+
188+
### Example: Changing Model on Resume
189+
190+
```typescript
191+
// Resume with a different model
192+
const session = await client.resumeSession("user-123-task-456", {
193+
model: "claude-sonnet-4", // Switch to a different model
194+
reasoningEffort: "high", // Increase reasoning effort
195+
});
196+
```
197+
167198
## Using BYOK (Bring Your Own Key) with Resumed Sessions
168199

169200
When using your own API keys, you must re-provide the provider configuration when resuming. API keys are never persisted to disk for security reasons.

dotnet/src/Client.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,19 +437,25 @@ public async Task<CopilotSession> ResumeSessionAsync(string sessionId, ResumeSes
437437

438438
var request = new ResumeSessionRequest(
439439
sessionId,
440+
config?.Model,
440441
config?.ReasoningEffort,
441442
config?.Tools?.Select(ToolDefinition.FromAIFunction).ToList(),
443+
config?.SystemMessage,
444+
config?.AvailableTools,
445+
config?.ExcludedTools,
442446
config?.Provider,
443447
config?.OnPermissionRequest != null ? true : null,
444448
config?.OnUserInputRequest != null ? true : null,
445449
hasHooks ? true : null,
446450
config?.WorkingDirectory,
451+
config?.ConfigDir,
447452
config?.DisableResume == true ? true : null,
448453
config?.Streaming == true ? true : null,
449454
config?.McpServers,
450455
config?.CustomAgents,
451456
config?.SkillDirectories,
452-
config?.DisabledSkills);
457+
config?.DisabledSkills,
458+
config?.InfiniteSessions);
453459

454460
var response = await InvokeRpcAsync<ResumeSessionResponse>(
455461
connection.Rpc, "session.resume", [request], cancellationToken);
@@ -1326,19 +1332,25 @@ internal record CreateSessionResponse(
13261332

13271333
internal record ResumeSessionRequest(
13281334
string SessionId,
1335+
string? Model,
13291336
string? ReasoningEffort,
13301337
List<ToolDefinition>? Tools,
1338+
SystemMessageConfig? SystemMessage,
1339+
List<string>? AvailableTools,
1340+
List<string>? ExcludedTools,
13311341
ProviderConfig? Provider,
13321342
bool? RequestPermission,
13331343
bool? RequestUserInput,
13341344
bool? Hooks,
13351345
string? WorkingDirectory,
1346+
string? ConfigDir,
13361347
bool? DisableResume,
13371348
bool? Streaming,
13381349
Dictionary<string, object>? McpServers,
13391350
List<CustomAgentConfig>? CustomAgents,
13401351
List<string>? SkillDirectories,
1341-
List<string>? DisabledSkills);
1352+
List<string>? DisabledSkills,
1353+
InfiniteSessionConfig? InfiniteSessions);
13421354

13431355
internal record ResumeSessionResponse(
13441356
string SessionId,

dotnet/src/Types.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,30 @@ public class SessionConfig
770770

771771
public class ResumeSessionConfig
772772
{
773+
/// <summary>
774+
/// Model to use for this session. Can change the model when resuming.
775+
/// </summary>
776+
public string? Model { get; set; }
777+
773778
public ICollection<AIFunction>? Tools { get; set; }
779+
780+
/// <summary>
781+
/// System message configuration.
782+
/// </summary>
783+
public SystemMessageConfig? SystemMessage { get; set; }
784+
785+
/// <summary>
786+
/// List of tool names to allow. When specified, only these tools will be available.
787+
/// Takes precedence over ExcludedTools.
788+
/// </summary>
789+
public List<string>? AvailableTools { get; set; }
790+
791+
/// <summary>
792+
/// List of tool names to disable. All other tools remain available.
793+
/// Ignored if AvailableTools is specified.
794+
/// </summary>
795+
public List<string>? ExcludedTools { get; set; }
796+
774797
public ProviderConfig? Provider { get; set; }
775798

776799
/// <summary>
@@ -801,6 +824,11 @@ public class ResumeSessionConfig
801824
/// </summary>
802825
public string? WorkingDirectory { get; set; }
803826

827+
/// <summary>
828+
/// Override the default configuration directory location.
829+
/// </summary>
830+
public string? ConfigDir { get; set; }
831+
804832
/// <summary>
805833
/// When true, the session.resume event is not emitted.
806834
/// Default: false (resume event is emitted).
@@ -834,6 +862,11 @@ public class ResumeSessionConfig
834862
/// List of skill names to disable.
835863
/// </summary>
836864
public List<string>? DisabledSkills { get; set; }
865+
866+
/// <summary>
867+
/// Infinite session configuration for persistent workspaces and automatic compaction.
868+
/// </summary>
869+
public InfiniteSessionConfig? InfiniteSessions { get; set; }
837870
}
838871

839872
public class MessageOptions

go/client.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,39 @@ func (c *Client) ResumeSessionWithOptions(ctx context.Context, sessionID string,
681681
}
682682

683683
if config != nil {
684+
if config.Model != "" {
685+
params["model"] = config.Model
686+
}
684687
if config.ReasoningEffort != "" {
685688
params["reasoningEffort"] = config.ReasoningEffort
686689
}
690+
if config.SystemMessage != nil {
691+
systemMessage := make(map[string]any)
692+
693+
if config.SystemMessage.Mode != "" {
694+
systemMessage["mode"] = config.SystemMessage.Mode
695+
}
696+
697+
if config.SystemMessage.Mode == "replace" {
698+
if config.SystemMessage.Content != "" {
699+
systemMessage["content"] = config.SystemMessage.Content
700+
}
701+
} else {
702+
if config.SystemMessage.Content != "" {
703+
systemMessage["content"] = config.SystemMessage.Content
704+
}
705+
}
706+
707+
if len(systemMessage) > 0 {
708+
params["systemMessage"] = systemMessage
709+
}
710+
}
711+
if len(config.AvailableTools) > 0 {
712+
params["availableTools"] = config.AvailableTools
713+
}
714+
if len(config.ExcludedTools) > 0 {
715+
params["excludedTools"] = config.ExcludedTools
716+
}
687717
if len(config.Tools) > 0 {
688718
toolDefs := make([]map[string]any, 0, len(config.Tools))
689719
for _, tool := range config.Tools {
@@ -731,6 +761,10 @@ func (c *Client) ResumeSessionWithOptions(ctx context.Context, sessionID string,
731761
if config.WorkingDirectory != "" {
732762
params["workingDirectory"] = config.WorkingDirectory
733763
}
764+
// Add config directory
765+
if config.ConfigDir != "" {
766+
params["configDir"] = config.ConfigDir
767+
}
734768
// Add disable resume flag
735769
if config.DisableResume {
736770
params["disableResume"] = true
@@ -774,6 +808,20 @@ func (c *Client) ResumeSessionWithOptions(ctx context.Context, sessionID string,
774808
if len(config.DisabledSkills) > 0 {
775809
params["disabledSkills"] = config.DisabledSkills
776810
}
811+
// Add infinite sessions configuration
812+
if config.InfiniteSessions != nil {
813+
infiniteSessions := map[string]any{}
814+
if config.InfiniteSessions.Enabled != nil {
815+
infiniteSessions["enabled"] = *config.InfiniteSessions.Enabled
816+
}
817+
if config.InfiniteSessions.BackgroundCompactionThreshold != nil {
818+
infiniteSessions["backgroundCompactionThreshold"] = *config.InfiniteSessions.BackgroundCompactionThreshold
819+
}
820+
if config.InfiniteSessions.BufferExhaustionThreshold != nil {
821+
infiniteSessions["bufferExhaustionThreshold"] = *config.InfiniteSessions.BufferExhaustionThreshold
822+
}
823+
params["infiniteSessions"] = infiniteSessions
824+
}
777825
}
778826

779827
result, err := c.client.Request("session.resume", params)

go/types.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,18 @@ type ToolResult struct {
399399

400400
// ResumeSessionConfig configures options when resuming a session
401401
type ResumeSessionConfig struct {
402+
// Model to use for this session. Can change the model when resuming.
403+
Model string
402404
// Tools exposes caller-implemented tools to the CLI
403405
Tools []Tool
406+
// SystemMessage configures system message customization
407+
SystemMessage *SystemMessageConfig
408+
// AvailableTools is a list of tool names to allow. When specified, only these tools will be available.
409+
// Takes precedence over ExcludedTools.
410+
AvailableTools []string
411+
// ExcludedTools is a list of tool names to disable. All other tools remain available.
412+
// Ignored if AvailableTools is specified.
413+
ExcludedTools []string
404414
// Provider configures a custom model provider
405415
Provider *ProviderConfig
406416
// ReasoningEffort level for models that support it.
@@ -415,6 +425,8 @@ type ResumeSessionConfig struct {
415425
// WorkingDirectory is the working directory for the session.
416426
// Tool operations will be relative to this directory.
417427
WorkingDirectory string
428+
// ConfigDir overrides the default configuration directory location.
429+
ConfigDir string
418430
// Streaming enables streaming of assistant message and reasoning chunks.
419431
// When true, assistant.message_delta and assistant.reasoning_delta events
420432
// with deltaContent are sent as the response is generated.
@@ -427,6 +439,8 @@ type ResumeSessionConfig struct {
427439
SkillDirectories []string
428440
// DisabledSkills is a list of skill names to disable
429441
DisabledSkills []string
442+
// InfiniteSessions configures infinite sessions for persistent workspaces and automatic compaction.
443+
InfiniteSessions *InfiniteSessionConfig
430444
// DisableResume, when true, skips emitting the session.resume event.
431445
// Useful for reconnecting to a session without triggering resume-related side effects.
432446
DisableResume bool

nodejs/package-lock.json

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodejs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"author": "GitHub",
4141
"license": "MIT",
4242
"dependencies": {
43-
"@github/copilot": "^0.0.402",
43+
"@github/copilot": "^0.0.403",
4444
"vscode-jsonrpc": "^8.2.1",
4545
"zod": "^4.3.6"
4646
},

0 commit comments

Comments
 (0)