Skip to content

Commit 25ad83a

Browse files
committed
Add missing options to ResumeSessionConfig for parity with SessionConfig
Port upstream PR #376: Add model, systemMessage, availableTools, excludedTools, configDir, and infiniteSessions to ResumeSessionConfig and ResumeSessionRequest.
1 parent c894502 commit 25ad83a

3 files changed

Lines changed: 237 additions & 0 deletions

File tree

src/main/java/com/github/copilot/sdk/CopilotClient.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,23 +630,29 @@ public CompletableFuture<CopilotSession> resumeSession(String sessionId, ResumeS
630630
var request = new ResumeSessionRequest();
631631
request.setSessionId(sessionId);
632632
if (config != null) {
633+
request.setModel(config.getModel());
633634
request.setReasoningEffort(config.getReasoningEffort());
634635
request.setTools(config.getTools() != null
635636
? config.getTools().stream()
636637
.map(t -> new ToolDef(t.getName(), t.getDescription(), t.getParameters()))
637638
.collect(Collectors.toList())
638639
: null);
640+
request.setSystemMessage(config.getSystemMessage());
641+
request.setAvailableTools(config.getAvailableTools());
642+
request.setExcludedTools(config.getExcludedTools());
639643
request.setProvider(config.getProvider());
640644
request.setRequestPermission(config.getOnPermissionRequest() != null ? true : null);
641645
request.setRequestUserInput(config.getOnUserInputRequest() != null ? true : null);
642646
request.setHooks(config.getHooks() != null && config.getHooks().hasHooks() ? true : null);
643647
request.setWorkingDirectory(config.getWorkingDirectory());
648+
request.setConfigDir(config.getConfigDir());
644649
request.setDisableResume(config.isDisableResume() ? true : null);
645650
request.setStreaming(config.isStreaming() ? true : null);
646651
request.setMcpServers(config.getMcpServers());
647652
request.setCustomAgents(config.getCustomAgents());
648653
request.setSkillDirectories(config.getSkillDirectories());
649654
request.setDisabledSkills(config.getDisabledSkills());
655+
request.setInfiniteSessions(config.getInfiniteSessions());
650656
}
651657

652658
return connection.rpc.invoke("session.resume", request, ResumeSessionResponse.class).thenApply(response -> {

src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,48 @@
3232
@JsonInclude(JsonInclude.Include.NON_NULL)
3333
public class ResumeSessionConfig {
3434

35+
private String model;
3536
private List<ToolDefinition> tools;
37+
private SystemMessageConfig systemMessage;
38+
private List<String> availableTools;
39+
private List<String> excludedTools;
3640
private ProviderConfig provider;
3741
private String reasoningEffort;
3842
private PermissionHandler onPermissionRequest;
3943
private UserInputHandler onUserInputRequest;
4044
private SessionHooks hooks;
4145
private String workingDirectory;
46+
private String configDir;
4247
private boolean disableResume;
4348
private boolean streaming;
4449
private Map<String, Object> mcpServers;
4550
private List<CustomAgentConfig> customAgents;
4651
private List<String> skillDirectories;
4752
private List<String> disabledSkills;
53+
private InfiniteSessionConfig infiniteSessions;
54+
55+
/**
56+
* Gets the AI model to use.
57+
*
58+
* @return the model name
59+
*/
60+
public String getModel() {
61+
return model;
62+
}
63+
64+
/**
65+
* Sets the AI model to use for the resumed session.
66+
* <p>
67+
* Can change the model when resuming an existing session.
68+
*
69+
* @param model
70+
* the model name
71+
* @return this config for method chaining
72+
*/
73+
public ResumeSessionConfig setModel(String model) {
74+
this.model = model;
75+
return this;
76+
}
4877

4978
/**
5079
* Gets the custom tools for this session.
@@ -68,6 +97,78 @@ public ResumeSessionConfig setTools(List<ToolDefinition> tools) {
6897
return this;
6998
}
7099

100+
/**
101+
* Gets the system message configuration.
102+
*
103+
* @return the system message config
104+
*/
105+
public SystemMessageConfig getSystemMessage() {
106+
return systemMessage;
107+
}
108+
109+
/**
110+
* Sets the system message configuration.
111+
* <p>
112+
* The system message controls the behavior and personality of the assistant.
113+
*
114+
* @param systemMessage
115+
* the system message configuration
116+
* @return this config for method chaining
117+
* @see SystemMessageConfig
118+
*/
119+
public ResumeSessionConfig setSystemMessage(SystemMessageConfig systemMessage) {
120+
this.systemMessage = systemMessage;
121+
return this;
122+
}
123+
124+
/**
125+
* Gets the list of allowed tool names.
126+
*
127+
* @return the list of available tool names
128+
*/
129+
public List<String> getAvailableTools() {
130+
return availableTools == null ? null : Collections.unmodifiableList(availableTools);
131+
}
132+
133+
/**
134+
* Sets the list of tool names that are allowed in this session.
135+
* <p>
136+
* When specified, only tools in this list will be available to the assistant.
137+
* Takes precedence over excluded tools.
138+
*
139+
* @param availableTools
140+
* the list of allowed tool names
141+
* @return this config for method chaining
142+
*/
143+
public ResumeSessionConfig setAvailableTools(List<String> availableTools) {
144+
this.availableTools = availableTools;
145+
return this;
146+
}
147+
148+
/**
149+
* Gets the list of excluded tool names.
150+
*
151+
* @return the list of excluded tool names
152+
*/
153+
public List<String> getExcludedTools() {
154+
return excludedTools == null ? null : Collections.unmodifiableList(excludedTools);
155+
}
156+
157+
/**
158+
* Sets the list of tool names to exclude from this session.
159+
* <p>
160+
* Tools in this list will not be available to the assistant. Ignored if
161+
* available tools is specified.
162+
*
163+
* @param excludedTools
164+
* the list of tool names to exclude
165+
* @return this config for method chaining
166+
*/
167+
public ResumeSessionConfig setExcludedTools(List<String> excludedTools) {
168+
this.excludedTools = excludedTools;
169+
return this;
170+
}
171+
71172
/**
72173
* Gets the custom API provider configuration.
73174
*
@@ -200,6 +301,29 @@ public ResumeSessionConfig setWorkingDirectory(String workingDirectory) {
200301
return this;
201302
}
202303

304+
/**
305+
* Gets the configuration directory path.
306+
*
307+
* @return the configuration directory path
308+
*/
309+
public String getConfigDir() {
310+
return configDir;
311+
}
312+
313+
/**
314+
* Sets the configuration directory path.
315+
* <p>
316+
* Override the default configuration directory location.
317+
*
318+
* @param configDir
319+
* the configuration directory path
320+
* @return this config for method chaining
321+
*/
322+
public ResumeSessionConfig setConfigDir(String configDir) {
323+
this.configDir = configDir;
324+
return this;
325+
}
326+
203327
/**
204328
* Returns whether the resume event is disabled.
205329
*
@@ -328,4 +452,27 @@ public ResumeSessionConfig setDisabledSkills(List<String> disabledSkills) {
328452
this.disabledSkills = disabledSkills;
329453
return this;
330454
}
455+
456+
/**
457+
* Gets the infinite session configuration.
458+
*
459+
* @return the infinite session config
460+
*/
461+
public InfiniteSessionConfig getInfiniteSessions() {
462+
return infiniteSessions;
463+
}
464+
465+
/**
466+
* Sets the infinite session configuration for persistent workspaces and
467+
* automatic compaction.
468+
*
469+
* @param infiniteSessions
470+
* the infinite session configuration
471+
* @return this config for method chaining
472+
* @see InfiniteSessionConfig
473+
*/
474+
public ResumeSessionConfig setInfiniteSessions(InfiniteSessionConfig infiniteSessions) {
475+
this.infiniteSessions = infiniteSessions;
476+
return this;
477+
}
331478
}

src/main/java/com/github/copilot/sdk/json/ResumeSessionRequest.java

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,24 @@ public final class ResumeSessionRequest {
2929
@JsonProperty("sessionId")
3030
private String sessionId;
3131

32+
@JsonProperty("model")
33+
private String model;
34+
3235
@JsonProperty("reasoningEffort")
3336
private String reasoningEffort;
3437

3538
@JsonProperty("tools")
3639
private List<ToolDef> tools;
3740

41+
@JsonProperty("systemMessage")
42+
private SystemMessageConfig systemMessage;
43+
44+
@JsonProperty("availableTools")
45+
private List<String> availableTools;
46+
47+
@JsonProperty("excludedTools")
48+
private List<String> excludedTools;
49+
3850
@JsonProperty("provider")
3951
private ProviderConfig provider;
4052

@@ -50,6 +62,9 @@ public final class ResumeSessionRequest {
5062
@JsonProperty("workingDirectory")
5163
private String workingDirectory;
5264

65+
@JsonProperty("configDir")
66+
private String configDir;
67+
5368
@JsonProperty("disableResume")
5469
private Boolean disableResume;
5570

@@ -68,6 +83,9 @@ public final class ResumeSessionRequest {
6883
@JsonProperty("disabledSkills")
6984
private List<String> disabledSkills;
7085

86+
@JsonProperty("infiniteSessions")
87+
private InfiniteSessionConfig infiniteSessions;
88+
7189
/** Gets the session ID. @return the session ID */
7290
public String getSessionId() {
7391
return sessionId;
@@ -78,6 +96,16 @@ public void setSessionId(String sessionId) {
7896
this.sessionId = sessionId;
7997
}
8098

99+
/** Gets the model name. @return the model */
100+
public String getModel() {
101+
return model;
102+
}
103+
104+
/** Sets the model name. @param model the model */
105+
public void setModel(String model) {
106+
this.model = model;
107+
}
108+
81109
/** Gets the reasoning effort. @return the reasoning effort level */
82110
public String getReasoningEffort() {
83111
return reasoningEffort;
@@ -100,6 +128,39 @@ public void setTools(List<ToolDef> tools) {
100128
this.tools = tools;
101129
}
102130

131+
/** Gets the system message config. @return the system message config */
132+
public SystemMessageConfig getSystemMessage() {
133+
return systemMessage;
134+
}
135+
136+
/**
137+
* Sets the system message config. @param systemMessage the system message
138+
* config
139+
*/
140+
public void setSystemMessage(SystemMessageConfig systemMessage) {
141+
this.systemMessage = systemMessage;
142+
}
143+
144+
/** Gets available tools. @return the available tool names */
145+
public List<String> getAvailableTools() {
146+
return availableTools == null ? null : Collections.unmodifiableList(availableTools);
147+
}
148+
149+
/** Sets available tools. @param availableTools the available tool names */
150+
public void setAvailableTools(List<String> availableTools) {
151+
this.availableTools = availableTools;
152+
}
153+
154+
/** Gets excluded tools. @return the excluded tool names */
155+
public List<String> getExcludedTools() {
156+
return excludedTools == null ? null : Collections.unmodifiableList(excludedTools);
157+
}
158+
159+
/** Sets excluded tools. @param excludedTools the excluded tool names */
160+
public void setExcludedTools(List<String> excludedTools) {
161+
this.excludedTools = excludedTools;
162+
}
163+
103164
/** Gets the provider config. @return the provider */
104165
public ProviderConfig getProvider() {
105166
return provider;
@@ -150,6 +211,16 @@ public void setWorkingDirectory(String workingDirectory) {
150211
this.workingDirectory = workingDirectory;
151212
}
152213

214+
/** Gets config directory. @return the config directory */
215+
public String getConfigDir() {
216+
return configDir;
217+
}
218+
219+
/** Sets config directory. @param configDir the config directory */
220+
public void setConfigDir(String configDir) {
221+
this.configDir = configDir;
222+
}
223+
153224
/** Gets disable resume flag. @return the flag */
154225
public Boolean getDisableResume() {
155226
return disableResume;
@@ -209,4 +280,17 @@ public List<String> getDisabledSkills() {
209280
public void setDisabledSkills(List<String> disabledSkills) {
210281
this.disabledSkills = disabledSkills;
211282
}
283+
284+
/** Gets infinite sessions config. @return the infinite sessions config */
285+
public InfiniteSessionConfig getInfiniteSessions() {
286+
return infiniteSessions;
287+
}
288+
289+
/**
290+
* Sets infinite sessions config. @param infiniteSessions the infinite sessions
291+
* config
292+
*/
293+
public void setInfiniteSessions(InfiniteSessionConfig infiniteSessions) {
294+
this.infiniteSessions = infiniteSessions;
295+
}
212296
}

0 commit comments

Comments
 (0)