Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions dotnet/src/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@ public async Task<CopilotSession> CreateSessionAsync(SessionConfig config, Cance
InstructionDirectories: config.InstructionDirectories,
PluginDirectories: config.PluginDirectories,
LargeOutput: config.LargeOutput,
ToolSearch: config.ToolSearch,
Memory: config.Memory,
Canvases: config.Canvases,
RequestCanvasRenderer: config.RequestCanvasRenderer,
Expand Down Expand Up @@ -1297,6 +1298,7 @@ public async Task<CopilotSession> ResumeSessionAsync(string sessionId, ResumeSes
InstructionDirectories: config.InstructionDirectories,
PluginDirectories: config.PluginDirectories,
LargeOutput: config.LargeOutput,
ToolSearch: config.ToolSearch,
Memory: config.Memory,
Canvases: config.Canvases,
RequestCanvasRenderer: config.RequestCanvasRenderer,
Expand Down Expand Up @@ -2630,6 +2632,7 @@ internal record CreateSessionRequest(
IList<string>? InstructionDirectories = null,
IList<string>? PluginDirectories = null,
LargeToolOutputConfig? LargeOutput = null,
ToolSearchConfig? ToolSearch = null,
MemoryConfiguration? Memory = null,
#pragma warning disable GHCP001
IList<CanvasDeclaration>? Canvases = null,
Expand Down Expand Up @@ -2729,6 +2732,7 @@ internal record ResumeSessionRequest(
IList<string>? InstructionDirectories = null,
IList<string>? PluginDirectories = null,
LargeToolOutputConfig? LargeOutput = null,
ToolSearchConfig? ToolSearch = null,
MemoryConfiguration? Memory = null,
#pragma warning disable GHCP001
IList<CanvasDeclaration>? Canvases = null,
Expand Down
38 changes: 38 additions & 0 deletions dotnet/src/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,12 @@ public sealed class ToolResultObject
[JsonPropertyName("toolTelemetry")]
public IDictionary<string, object>? ToolTelemetry { get; set; }

/// <summary>
/// Names of tools returned by a tool-search tool.
/// </summary>
[JsonPropertyName("toolReferences")]
public IList<string>? ToolReferences { get; set; }

/// <summary>
/// Converts the result of an <see cref="AIFunction"/> invocation into a
/// <see cref="ToolResultObject"/>. Handles <see cref="ToolResultAIContent"/>,
Expand Down Expand Up @@ -2703,6 +2709,30 @@ public sealed class LargeToolOutputConfig
public string? OutputDirectory { get; set; }
}

/// <summary>
/// Overrides the runtime's built-in tool-search behavior.
/// Defers toolsto keep the model's active tool set small.
Comment thread
almaleksia marked this conversation as resolved.
Outdated
/// To override the tool-search tool's implementation, register a tool
/// named "tool_search_tool" with <c>OverridesBuiltInTool</c> set to
/// <see langword="true"/>.
/// </summary>
public sealed class ToolSearchConfig
{
/// <summary>
/// Enable or disable tool search.
/// </summary>
[JsonPropertyName("enabled")]
public bool? Enabled { get; set; }

/// <summary>
/// The tool count above which MCP and external tools are deferred behind
/// tool search. When <see langword="null"/>, the runtime default (30)
/// applies.
/// </summary>
[JsonPropertyName("deferThreshold")]
public int? DeferThreshold { get; set; }
}

/// <summary>
/// Configuration for session memory.
/// </summary>
Expand Down Expand Up @@ -2811,6 +2841,7 @@ protected SessionConfigBase(SessionConfigBase? other)
Hooks = other.Hooks;
InfiniteSessions = other.InfiniteSessions;
LargeOutput = other.LargeOutput;
ToolSearch = other.ToolSearch;
Memory = other.Memory;
McpServers = other.McpServers is not null
? (other.McpServers is Dictionary<string, McpServerConfig> dict
Expand Down Expand Up @@ -3215,6 +3246,13 @@ protected SessionConfigBase(SessionConfigBase? other)
/// </summary>
public LargeToolOutputConfig? LargeOutput { get; set; }

/// <summary>
/// Overrides the runtime's built-in tool-search behavior.
/// Tool search defers tools to keep the model's active tool set small. When <see langword="null"/>,
/// the runtime default applies.
/// </summary>
public ToolSearchConfig? ToolSearch { get; set; }

/// <summary>
/// Configuration for session memory. When set, controls whether the
/// session can read and write persistent memory.
Expand Down
2 changes: 2 additions & 0 deletions go/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ func (c *Client) CreateSession(ctx context.Context, config *SessionConfig) (*Ses
req.DisabledSkills = config.DisabledSkills
req.InfiniteSessions = config.InfiniteSessions
req.LargeOutput = config.LargeOutput
req.ToolSearch = config.ToolSearch
req.Memory = config.Memory
req.GitHubToken = config.GitHubToken
req.RemoteSession = config.RemoteSession
Expand Down Expand Up @@ -1085,6 +1086,7 @@ func (c *Client) ResumeSessionWithOptions(ctx context.Context, sessionID string,
req.DisabledSkills = config.DisabledSkills
req.InfiniteSessions = config.InfiniteSessions
req.LargeOutput = config.LargeOutput
req.ToolSearch = config.ToolSearch
req.Memory = config.Memory
req.GitHubToken = config.GitHubToken
req.RemoteSession = config.RemoteSession
Expand Down
1 change: 1 addition & 0 deletions go/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,7 @@ func (s *Session) executeToolAndRespond(requestID, toolName, toolCallID string,
TextResultForLlm: textResultForLLM,
ToolTelemetry: result.ToolTelemetry,
ResultType: &effectiveResultType,
ToolReferences: result.ToolReferences,
}
if result.Error != "" {
rpcResult.Error = &result.Error
Expand Down
24 changes: 24 additions & 0 deletions go/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,18 @@ type LargeToolOutputConfig struct {
OutputDirectory string `json:"outputDir,omitempty"`
}

// ToolSearchConfig allows to configure tool search behavior.
// Tool search defers tools to keep the model's active tool set small.
// To override the tool-search tool's implementation, register a
// [Tool] named "tool_search_tool" with OverridesBuiltInTool set to true.
type ToolSearchConfig struct {
// Controls whether tool search is enabled.
Enabled *bool `json:"enabled,omitempty"`
// DeferThreshold is the tool count above which MCP and external tools are
// deferred behind tool search. When nil, the runtime default (30) applies.
DeferThreshold *int `json:"deferThreshold,omitempty"`
}

// SessionFSCapabilities declares optional provider capabilities.
type SessionFSCapabilities struct {
// Sqlite indicates whether the provider supports SQLite query/exists operations.
Expand Down Expand Up @@ -1153,6 +1165,10 @@ type SessionConfig struct {
// output exceeding the configured size, the output is written to a temp file
// and a reference is returned to the model instead of the full payload.
LargeOutput *LargeToolOutputConfig
// ToolSearch overrides the runtime's built-in tool-search behavior, which
// defers rarely used tools behind a searchable index. When nil, the runtime
// default applies.
ToolSearch *ToolSearchConfig
// Memory configures the memory feature for the session. When omitted, the
// runtime default applies.
Memory *MemoryConfiguration
Expand Down Expand Up @@ -1300,6 +1316,8 @@ type ToolResult struct {
Error string `json:"error,omitempty"`
SessionLog string `json:"sessionLog,omitempty"`
ToolTelemetry map[string]any `json:"toolTelemetry,omitempty"`
// ToolReferences lists names of tools returned by a tool-search tool.
ToolReferences []string `json:"toolReferences,omitempty"`
}

// CommandContext provides context about a slash-command invocation.
Expand Down Expand Up @@ -1596,6 +1614,10 @@ type ResumeSessionConfig struct {
// output exceeding the configured size, the output is written to a temp file
// and a reference is returned to the model instead of the full payload.
LargeOutput *LargeToolOutputConfig
// ToolSearch overrides the runtime's built-in tool-search behavior, which
// defers rarely used tools behind a searchable index. When nil, the runtime
// default applies.
ToolSearch *ToolSearchConfig
// Memory configures the memory feature for the session. When omitted, the
// runtime default applies.
Memory *MemoryConfiguration
Expand Down Expand Up @@ -2109,6 +2131,7 @@ type createSessionRequest struct {
DisabledSkills []string `json:"disabledSkills,omitempty"`
InfiniteSessions *InfiniteSessionConfig `json:"infiniteSessions,omitempty"`
LargeOutput *LargeToolOutputConfig `json:"largeOutput,omitempty"`
ToolSearch *ToolSearchConfig `json:"toolSearch,omitempty"`
Memory *MemoryConfiguration `json:"memory,omitempty"`
Commands []wireCommand `json:"commands,omitempty"`
RequestElicitation *bool `json:"requestElicitation,omitempty"`
Expand Down Expand Up @@ -2198,6 +2221,7 @@ type resumeSessionRequest struct {
DisabledSkills []string `json:"disabledSkills,omitempty"`
InfiniteSessions *InfiniteSessionConfig `json:"infiniteSessions,omitempty"`
LargeOutput *LargeToolOutputConfig `json:"largeOutput,omitempty"`
ToolSearch *ToolSearchConfig `json:"toolSearch,omitempty"`
Memory *MemoryConfiguration `json:"memory,omitempty"`
Commands []wireCommand `json:"commands,omitempty"`
RequestElicitation *bool `json:"requestElicitation,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ static CreateSessionRequest buildCreateRequest(SessionConfig config, String sess
request.setInstructionDirectories(config.getInstructionDirectories());
request.setPluginDirectories(config.getPluginDirectories());
request.setLargeOutput(config.getLargeOutput());
request.setToolSearch(config.getToolSearch());
request.setMemory(config.getMemory());
request.setDisabledSkills(config.getDisabledSkills());
request.setConfigDirectory(config.getConfigDirectory());
Expand Down Expand Up @@ -280,6 +281,7 @@ static ResumeSessionRequest buildResumeRequest(String sessionId, ResumeSessionCo
request.setInstructionDirectories(config.getInstructionDirectories());
request.setPluginDirectories(config.getPluginDirectories());
request.setLargeOutput(config.getLargeOutput());
request.setToolSearch(config.getToolSearch());
request.setMemory(config.getMemory());
request.setDisabledSkills(config.getDisabledSkills());
request.setInfiniteSessions(config.getInfiniteSessions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ public final class CreateSessionRequest {
@JsonProperty("largeOutput")
private LargeToolOutputConfig largeOutput;

@JsonProperty("toolSearch")
private ToolSearchConfig toolSearch;

@JsonProperty("memory")
private MemoryConfiguration memory;

Expand Down Expand Up @@ -620,6 +623,16 @@ public void setLargeOutput(LargeToolOutputConfig largeOutput) {
this.largeOutput = largeOutput;
}

/** Gets tool-search config. @return the tool-search config */
public ToolSearchConfig getToolSearch() {
return toolSearch;
}

/** Sets tool-search config. @param toolSearch the tool-search config */
public void setToolSearch(ToolSearchConfig toolSearch) {
this.toolSearch = toolSearch;
}

/** Gets memory config. @return the memory config */
public MemoryConfiguration getMemory() {
return memory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public class ResumeSessionConfig {
private List<String> instructionDirectories;
private List<String> pluginDirectories;
private LargeToolOutputConfig largeOutput;
private ToolSearchConfig toolSearch;
private MemoryConfiguration memory;
private List<String> disabledSkills;
private InfiniteSessionConfig infiniteSessions;
Expand Down Expand Up @@ -1446,6 +1447,27 @@ public ResumeSessionConfig setLargeOutput(LargeToolOutputConfig largeOutput) {
return this;
}

/**
* Gets the tool-search configuration.
*
* @return the tool-search config, or {@code null} for the runtime default
*/
public ToolSearchConfig getToolSearch() {
return toolSearch;
}

/**
* Sets the tool-search configuration.
*
* @param toolSearch
* the tool-search config
* @return this config for method chaining
*/
public ResumeSessionConfig setToolSearch(ToolSearchConfig toolSearch) {
this.toolSearch = toolSearch;
return this;
}

/**
* Gets the configuration for session memory.
*
Expand Down Expand Up @@ -1806,6 +1828,7 @@ public ResumeSessionConfig clone() {
: null;
copy.pluginDirectories = this.pluginDirectories != null ? new ArrayList<>(this.pluginDirectories) : null;
copy.largeOutput = this.largeOutput;
copy.toolSearch = this.toolSearch;
copy.memory = this.memory;
copy.disabledSkills = this.disabledSkills != null ? new ArrayList<>(this.disabledSkills) : null;
copy.infiniteSessions = this.infiniteSessions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public final class ResumeSessionRequest {
@JsonProperty("largeOutput")
private LargeToolOutputConfig largeOutput;

@JsonProperty("toolSearch")
private ToolSearchConfig toolSearch;

@JsonProperty("memory")
private MemoryConfiguration memory;

Expand Down Expand Up @@ -836,6 +839,16 @@ public void setLargeOutput(LargeToolOutputConfig largeOutput) {
this.largeOutput = largeOutput;
}

/** Gets tool-search config. @return the tool-search config */
public ToolSearchConfig getToolSearch() {
return toolSearch;
}

/** Sets tool-search config. @param toolSearch the tool-search config */
public void setToolSearch(ToolSearchConfig toolSearch) {
this.toolSearch = toolSearch;
}

/** Gets memory config. @return the memory config */
public MemoryConfiguration getMemory() {
return memory;
Expand Down
24 changes: 24 additions & 0 deletions java/src/main/java/com/github/copilot/rpc/SessionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class SessionConfig {
private List<String> instructionDirectories;
private List<String> pluginDirectories;
private LargeToolOutputConfig largeOutput;
private ToolSearchConfig toolSearch;
private MemoryConfiguration memory;
private List<String> disabledSkills;
private String configDirectory;
Expand Down Expand Up @@ -1129,6 +1130,28 @@ public SessionConfig setLargeOutput(LargeToolOutputConfig largeOutput) {
return this;
}

/**
* Gets the tool-search override configuration.
*
* @return the tool-search config, or {@code null} for the runtime default
*/
public ToolSearchConfig getToolSearch() {
return toolSearch;
}

/**
* Sets the tool-search override configuration. When {@code null}, the runtime
* default tool-search behavior applies.
*
* @param toolSearch
* the tool-search config
* @return this config instance for method chaining
*/
public SessionConfig setToolSearch(ToolSearchConfig toolSearch) {
this.toolSearch = toolSearch;
return this;
}

/**
* Gets the configuration for session memory.
*
Expand Down Expand Up @@ -1931,6 +1954,7 @@ public SessionConfig clone() {
: null;
copy.pluginDirectories = this.pluginDirectories != null ? new ArrayList<>(this.pluginDirectories) : null;
copy.largeOutput = this.largeOutput;
copy.toolSearch = this.toolSearch;
copy.memory = this.memory;
copy.disabledSkills = this.disabledSkills != null ? new ArrayList<>(this.disabledSkills) : null;
copy.configDirectory = this.configDirectory;
Expand Down
Loading
Loading