Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions dotnet/src/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,8 @@ public async Task<CopilotSession> CreateSessionAsync(SessionConfig config, Cance
GitHubToken: config.GitHubToken,
RemoteSession: config.RemoteSession,
Cloud: config.Cloud,
InstructionDirectories: config.InstructionDirectories);
InstructionDirectories: config.InstructionDirectories,
IncludeCurrentDatetime: config.IncludeCurrentDatetime);

var rpcTimestamp = Stopwatch.GetTimestamp();
var response = await InvokeRpcAsync<CreateSessionResponse>(
Expand Down Expand Up @@ -778,7 +779,8 @@ public async Task<CopilotSession> ResumeSessionAsync(string sessionId, ResumeSes
GitHubToken: config.GitHubToken,
RemoteSession: config.RemoteSession,
ContinuePendingWork: config.ContinuePendingWork,
InstructionDirectories: config.InstructionDirectories);
InstructionDirectories: config.InstructionDirectories,
IncludeCurrentDatetime: config.IncludeCurrentDatetime);

var rpcTimestamp = Stopwatch.GetTimestamp();
var response = await InvokeRpcAsync<ResumeSessionResponse>(
Expand Down Expand Up @@ -1866,7 +1868,8 @@ internal record CreateSessionRequest(
string? GitHubToken = null,
RemoteSessionMode? RemoteSession = null,
CloudSessionOptions? Cloud = null,
IList<string>? InstructionDirectories = null);
IList<string>? InstructionDirectories = null,
bool? IncludeCurrentDatetime = null);

internal record ToolDefinition(
string Name,
Expand Down Expand Up @@ -1928,7 +1931,8 @@ internal record ResumeSessionRequest(
string? GitHubToken = null,
RemoteSessionMode? RemoteSession = null,
bool? ContinuePendingWork = null,
IList<string>? InstructionDirectories = null);
IList<string>? InstructionDirectories = null,
bool? IncludeCurrentDatetime = null);

internal record ResumeSessionResponse(
string SessionId,
Expand Down
7 changes: 7 additions & 0 deletions dotnet/src/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2214,6 +2214,7 @@ protected SessionConfigBase(SessionConfigBase? other)
OnUserInputRequest = other.OnUserInputRequest;
Provider = other.Provider;
EnableSessionTelemetry = other.EnableSessionTelemetry;
IncludeCurrentDatetime = other.IncludeCurrentDatetime;
ReasoningEffort = other.ReasoningEffort;
CreateSessionFsProvider = other.CreateSessionFsProvider;
GitHubToken = other.GitHubToken;
Expand Down Expand Up @@ -2292,6 +2293,12 @@ protected SessionConfigBase(SessionConfigBase? other)
/// </summary>
public bool? EnableSessionTelemetry { get; set; }

/// <summary>
/// When false, suppresses current_datetime injection in the model-facing user message.
/// Defaults to true (datetime is included) when null.
/// </summary>
public bool? IncludeCurrentDatetime { get; set; }

/// <summary>Handler for permission requests from the server.</summary>
public Func<PermissionRequest, PermissionInvocation, Task<PermissionDecision>>? OnPermissionRequest { get; set; }

Expand Down
2 changes: 2 additions & 0 deletions go/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ func (c *Client) CreateSession(ctx context.Context, config *SessionConfig) (*Ses
req.ExcludedTools = config.ExcludedTools
req.Provider = config.Provider
req.EnableSessionTelemetry = config.EnableSessionTelemetry
req.IncludeCurrentDatetime = config.IncludeCurrentDatetime
req.ModelCapabilities = config.ModelCapabilities
req.WorkingDirectory = config.WorkingDirectory
req.MCPServers = config.MCPServers
Expand Down Expand Up @@ -796,6 +797,7 @@ func (c *Client) ResumeSessionWithOptions(ctx context.Context, sessionID string,
req.Tools = config.Tools
req.Provider = config.Provider
req.EnableSessionTelemetry = config.EnableSessionTelemetry
req.IncludeCurrentDatetime = config.IncludeCurrentDatetime
req.ModelCapabilities = config.ModelCapabilities
req.AvailableTools = config.AvailableTools
req.ExcludedTools = config.ExcludedTools
Expand Down
10 changes: 10 additions & 0 deletions go/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,10 @@ type SessionConfig struct {
// regardless of this setting. This is independent of the OpenTelemetry
// configuration in ClientOptions.Telemetry.
EnableSessionTelemetry *bool
// IncludeCurrentDatetime includes the current local datetime in model-facing user messages.
// When false, suppresses the injected <current_datetime> tag. When nil, defaults
// to true for backwards compatibility.
IncludeCurrentDatetime *bool
// ModelCapabilities overrides individual model capabilities resolved by the runtime.
// Only non-nil fields are applied over the runtime-resolved capabilities.
ModelCapabilities *rpc.ModelCapabilitiesOverride
Expand Down Expand Up @@ -1084,6 +1088,10 @@ type ResumeSessionConfig struct {
// regardless of this setting. This is independent of the OpenTelemetry
// configuration in ClientOptions.Telemetry.
EnableSessionTelemetry *bool
// IncludeCurrentDatetime includes the current local datetime in model-facing user messages.
// When false, suppresses the injected <current_datetime> tag. When nil, defaults
// to true for backwards compatibility.
IncludeCurrentDatetime *bool
// ModelCapabilities overrides individual model capabilities resolved by the runtime.
// Only non-nil fields are applied over the runtime-resolved capabilities.
ModelCapabilities *rpc.ModelCapabilitiesOverride
Expand Down Expand Up @@ -1374,6 +1382,7 @@ type createSessionRequest struct {
ExcludedTools []string `json:"excludedTools,omitempty"`
Provider *ProviderConfig `json:"provider,omitempty"`
EnableSessionTelemetry *bool `json:"enableSessionTelemetry,omitempty"`
IncludeCurrentDatetime *bool `json:"includeCurrentDatetime,omitempty"`
ModelCapabilities *rpc.ModelCapabilitiesOverride `json:"modelCapabilities,omitempty"`
RequestPermission *bool `json:"requestPermission,omitempty"`
RequestUserInput *bool `json:"requestUserInput,omitempty"`
Expand Down Expand Up @@ -1428,6 +1437,7 @@ type resumeSessionRequest struct {
ExcludedTools []string `json:"excludedTools,omitempty"`
Provider *ProviderConfig `json:"provider,omitempty"`
EnableSessionTelemetry *bool `json:"enableSessionTelemetry,omitempty"`
IncludeCurrentDatetime *bool `json:"includeCurrentDatetime,omitempty"`
ModelCapabilities *rpc.ModelCapabilitiesOverride `json:"modelCapabilities,omitempty"`
RequestPermission *bool `json:"requestPermission,omitempty"`
RequestUserInput *bool `json:"requestUserInput,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ static CreateSessionRequest buildCreateRequest(SessionConfig config, String sess
request.setExcludedTools(config.getExcludedTools());
request.setProvider(config.getProvider());
config.getEnableSessionTelemetry().ifPresent(request::setEnableSessionTelemetry);
config.getIncludeCurrentDatetime().ifPresent(request::setIncludeCurrentDatetime);
if (config.getOnUserInputRequest() != null) {
request.setRequestUserInput(true);
}
Expand Down Expand Up @@ -203,6 +204,7 @@ static ResumeSessionRequest buildResumeRequest(String sessionId, ResumeSessionCo
request.setExcludedTools(config.getExcludedTools());
request.setProvider(config.getProvider());
config.getEnableSessionTelemetry().ifPresent(request::setEnableSessionTelemetry);
config.getIncludeCurrentDatetime().ifPresent(request::setIncludeCurrentDatetime);
if (config.getOnUserInputRequest() != null) {
request.setRequestUserInput(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public final class CreateSessionRequest {
@JsonProperty("enableSessionTelemetry")
private Boolean enableSessionTelemetry;

@JsonProperty("includeCurrentDatetime")
private Boolean includeCurrentDatetime;

@JsonProperty("requestPermission")
private Boolean requestPermission;

Expand Down Expand Up @@ -241,6 +244,25 @@ public void clearEnableSessionTelemetry() {
this.enableSessionTelemetry = null;
}

/** Gets include current datetime flag. @return the flag */
public Boolean getIncludeCurrentDatetime() {
return includeCurrentDatetime;
}

/**
* Sets include current datetime flag. @param includeCurrentDatetime the flag
*/
public void setIncludeCurrentDatetime(Boolean includeCurrentDatetime) {
this.includeCurrentDatetime = includeCurrentDatetime;
}

/**
* Clears the includeCurrentDatetime setting, reverting to the default behavior.
*/
public void clearIncludeCurrentDatetime() {
this.includeCurrentDatetime = null;
}

/** Gets request permission flag. @return the flag */
public Boolean getRequestPermission() {
return requestPermission;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class ResumeSessionConfig {
private List<String> excludedTools;
private ProviderConfig provider;
private Boolean enableSessionTelemetry;
private Boolean includeCurrentDatetime;
private String reasoningEffort;
private ModelCapabilitiesOverride modelCapabilities;
private PermissionHandler onPermissionRequest;
Expand Down Expand Up @@ -279,6 +280,46 @@ public ResumeSessionConfig clearEnableSessionTelemetry() {
return this;
}

/**
* Gets whether the current local datetime is included in model-facing user
* messages.
*
* @return an {@link java.util.Optional} containing {@code true} to include the
* current datetime or {@code false} to suppress it, or
* {@link java.util.Optional#empty()} to use the runtime default
*/
@JsonIgnore
public Optional<Boolean> getIncludeCurrentDatetime() {
return Optional.ofNullable(includeCurrentDatetime);
}

/**
* Sets whether to include the current local datetime in model-facing user
* messages.
* <p>
* When {@code false}, suppresses the injected {@code <current_datetime>} tag.
* Default: {@code true}.
*
* @param includeCurrentDatetime
* {@code true} to include the current datetime, {@code false} to
* suppress it, or {@code null} to use the runtime default
* @return this config for method chaining
*/
public ResumeSessionConfig setIncludeCurrentDatetime(Boolean includeCurrentDatetime) {
this.includeCurrentDatetime = includeCurrentDatetime;
return this;
}

/**
* Clears the includeCurrentDatetime setting, reverting to the default behavior.
*
* @return this instance for method chaining
*/
public ResumeSessionConfig clearIncludeCurrentDatetime() {
this.includeCurrentDatetime = null;
return this;
}

/**
* Gets the reasoning effort level.
*
Expand Down Expand Up @@ -937,6 +978,7 @@ public ResumeSessionConfig clone() {
copy.excludedTools = this.excludedTools != null ? new ArrayList<>(this.excludedTools) : null;
copy.provider = this.provider;
copy.enableSessionTelemetry = this.enableSessionTelemetry;
copy.includeCurrentDatetime = this.includeCurrentDatetime;
copy.reasoningEffort = this.reasoningEffort;
copy.modelCapabilities = this.modelCapabilities;
copy.onPermissionRequest = this.onPermissionRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public final class ResumeSessionRequest {
@JsonProperty("enableSessionTelemetry")
private Boolean enableSessionTelemetry;

@JsonProperty("includeCurrentDatetime")
private Boolean includeCurrentDatetime;

@JsonProperty("requestPermission")
private Boolean requestPermission;

Expand Down Expand Up @@ -245,6 +248,25 @@ public void clearEnableSessionTelemetry() {
this.enableSessionTelemetry = null;
}

/** Gets include current datetime flag. @return the flag */
public Boolean getIncludeCurrentDatetime() {
return includeCurrentDatetime;
}

/**
* Sets include current datetime flag. @param includeCurrentDatetime the flag
*/
public void setIncludeCurrentDatetime(Boolean includeCurrentDatetime) {
this.includeCurrentDatetime = includeCurrentDatetime;
}

/**
* Clears the includeCurrentDatetime setting, reverting to the default behavior.
*/
public void clearIncludeCurrentDatetime() {
this.includeCurrentDatetime = null;
}

/** Gets request permission flag. @return the flag */
public Boolean getRequestPermission() {
return requestPermission;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class SessionConfig {
private List<String> excludedTools;
private ProviderConfig provider;
private Boolean enableSessionTelemetry;
private Boolean includeCurrentDatetime;
private PermissionHandler onPermissionRequest;
private UserInputHandler onUserInputRequest;
private SessionHooks hooks;
Expand Down Expand Up @@ -334,6 +335,46 @@ public SessionConfig clearEnableSessionTelemetry() {
return this;
}

/**
* Gets whether the current local datetime is included in model-facing user
* messages.
*
* @return an {@link java.util.Optional} containing {@code true} to include the
* current datetime or {@code false} to suppress it, or
* {@link java.util.Optional#empty()} to use the runtime default
*/
@JsonIgnore
public Optional<Boolean> getIncludeCurrentDatetime() {
return Optional.ofNullable(includeCurrentDatetime);
}

/**
* Sets whether to include the current local datetime in model-facing user
* messages.
* <p>
* When {@code false}, suppresses the injected {@code <current_datetime>} tag.
* Default: {@code true}.
*
* @param includeCurrentDatetime
* {@code true} to include the current datetime, {@code false} to
* suppress it, or {@code null} to use the runtime default
* @return this config instance for method chaining
*/
public SessionConfig setIncludeCurrentDatetime(Boolean includeCurrentDatetime) {
this.includeCurrentDatetime = includeCurrentDatetime;
return this;
}

/**
* Clears the includeCurrentDatetime setting, reverting to the default behavior.
*
* @return this instance for method chaining
*/
public SessionConfig clearIncludeCurrentDatetime() {
this.includeCurrentDatetime = null;
return this;
}

/**
* Gets the permission request handler.
*
Expand Down Expand Up @@ -1033,6 +1074,7 @@ public SessionConfig clone() {
copy.excludedTools = this.excludedTools != null ? new ArrayList<>(this.excludedTools) : null;
copy.provider = this.provider;
copy.enableSessionTelemetry = this.enableSessionTelemetry;
copy.includeCurrentDatetime = this.includeCurrentDatetime;
copy.onPermissionRequest = this.onPermissionRequest;
copy.onUserInputRequest = this.onUserInputRequest;
copy.hooks = this.hooks;
Expand Down
38 changes: 38 additions & 0 deletions java/src/test/java/com/github/copilot/sdk/ConfigCloneTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,25 @@ void sessionConfigEnableSessionTelemetryDefaultIsNull() {
assertTrue(cloned.getEnableSessionTelemetry().isEmpty());
}

@Test
void sessionConfigIncludeCurrentDatetimeCopied() {
SessionConfig original = new SessionConfig();
original.setIncludeCurrentDatetime(false);

SessionConfig cloned = original.clone();

assertFalse(cloned.getIncludeCurrentDatetime().orElse(true));
}

@Test
void sessionConfigIncludeCurrentDatetimeDefaultIsNull() {
SessionConfig original = new SessionConfig();

SessionConfig cloned = original.clone();

assertTrue(cloned.getIncludeCurrentDatetime().isEmpty());
}

@Test
void resumeSessionConfigEnableSessionTelemetryCopied() {
ResumeSessionConfig original = new ResumeSessionConfig();
Expand All @@ -234,6 +253,25 @@ void resumeSessionConfigEnableSessionTelemetryDefaultIsNull() {
assertTrue(cloned.getEnableSessionTelemetry().isEmpty());
}

@Test
void resumeSessionConfigIncludeCurrentDatetimeCopied() {
ResumeSessionConfig original = new ResumeSessionConfig();
original.setIncludeCurrentDatetime(false);

ResumeSessionConfig cloned = original.clone();

assertFalse(cloned.getIncludeCurrentDatetime().orElse(true));
}

@Test
void resumeSessionConfigIncludeCurrentDatetimeDefaultIsNull() {
ResumeSessionConfig original = new ResumeSessionConfig();

ResumeSessionConfig cloned = original.clone();

assertTrue(cloned.getIncludeCurrentDatetime().isEmpty());
}

@Test
void clonePreservesNullFields() {
CopilotClientOptions opts = new CopilotClientOptions();
Expand Down
Loading
Loading