Skip to content

Add defer parameter to tool definition#1632

Merged
SteveSandersonMS merged 2 commits into
github:mainfrom
almaleksia:defer-parameter-for-tools
Jun 12, 2026
Merged

Add defer parameter to tool definition#1632
SteveSandersonMS merged 2 commits into
github:mainfrom
almaleksia:defer-parameter-for-tools

Conversation

@almaleksia

Copy link
Copy Markdown
Contributor

This PR adds defer parameter to tool definition that allows to configure tool deferral and pre-loading when tool search is activated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an optional defer parameter to tool definitions across the SDKs, enabling the runtime/CLI to lazily load tools via tool search (or force pre-loading) based on an explicit deferral mode.

Changes:

  • Introduces a defer/Defer field (auto/never) on tool definitions across Rust, Python, Node.js, Go, Java, and .NET.
  • Wires defer through session create/resume request payloads where tools are serialized.
  • Adds/updates unit tests and READMEs to document and validate defer serialization/omission behavior.
Show a summary per file
File Description
rust/src/types.rs Adds defer: Option<DeferMode> to Tool, plus enum + builder + serialization test.
python/test_client.py Adds tests asserting defer is sent on session.create/session.resume.
python/README.md Documents Python tool deferral usage via defer="auto" | "never".
python/copilot/tools.py Adds defer to Tool and define_tool(...) API + docstring.
python/copilot/client.py Forwards tool.defer into tool definitions for create/resume payloads.
nodejs/test/client.test.ts Adds tests asserting defer is included in tool defs for create/resume.
nodejs/src/types.ts Extends Tool/defineTool types with optional defer?: "auto" | "never".
nodejs/src/client.ts Forwards defer into tool definitions for create/resume payloads.
nodejs/README.md Documents Node tool deferral usage via defer: "auto" | "never".
java/src/test/java/com/github/copilot/ToolDefinitionTest.java Adds serialization tests for Java ToolDefinition.defer.
java/src/main/java/com/github/copilot/rpc/ToolDefinition.java Adds defer field to RPC tool definition + new factory method.
java/src/main/java/com/github/copilot/rpc/ToolDefer.java Introduces ToolDefer enum with JSON (de)serialization.
go/types.go Adds ToolDefer type + Tool.Defer JSON field.
go/README.md Documents Go tool deferral usage (ToolDeferAuto / ToolDeferNever).
go/client_test.go Adds tests for defer serialization and omission when unset.
dotnet/test/Unit/CopilotToolTests.cs Extends unit tests to cover Defer metadata propagation.
dotnet/src/CopilotTool.cs Adds CopilotToolDefer + CopilotToolOptions.Defer and metadata wiring.
dotnet/src/Client.cs Adds Defer to internal RPC tool definition mapping + source-gen metadata.
dotnet/README.md Documents .NET tool deferral usage (CopilotToolOptions.Defer).

Copilot's findings

  • Files reviewed: 19/19 changed files
  • Comments generated: 1

Comment thread java/src/main/java/com/github/copilot/rpc/ToolDefinition.java
@almaleksia almaleksia force-pushed the defer-parameter-for-tools branch from fc3b1ae to 365b573 Compare June 11, 2026 15:18
@almaleksia almaleksia changed the title Add defer parameter to tool definition Add defer parameter to tool definition Jun 11, 2026
@almaleksia almaleksia marked this pull request as ready for review June 11, 2026 15:41
@almaleksia almaleksia requested a review from a team as a code owner June 11, 2026 15:41
Comment thread dotnet/README.md Outdated

#### Deferring Tools

Set `CopilotToolOptions.Defer` to control whether a tool may be loaded lazily via tool search rather than always pre-loaded. Use `CopilotToolDefer.Auto` to allow the tool to be deferred and surfaced through tool search, or `CopilotToolDefer.Never` to force it to always be pre-loaded. When unset, the runtime decides.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming confuses me a bit. Is CopilotToolDefer.Auto exactly equivalent to not setting a value, or does it mean something different?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is the same - value defaults to "auto" currently. Fixed all occurences in docs/comments.

@SteveSandersonMS SteveSandersonMS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@SteveSandersonMS SteveSandersonMS added this pull request to the merge queue Jun 12, 2026
Merged via the queue into github:main with commit 736bd6e Jun 12, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants