Add defer parameter to tool definition#1632
Merged
SteveSandersonMS merged 2 commits intoJun 12, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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/Deferfield (auto/never) on tool definitions across Rust, Python, Node.js, Go, Java, and .NET. - Wires
deferthrough session create/resume request payloads where tools are serialized. - Adds/updates unit tests and READMEs to document and validate
deferserialization/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
fc3b1ae to
365b573
Compare
defer parameter to tool definition
|
|
||
| #### 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. |
Contributor
There was a problem hiding this comment.
The naming confuses me a bit. Is CopilotToolDefer.Auto exactly equivalent to not setting a value, or does it mean something different?
Contributor
Author
There was a problem hiding this comment.
Yes it is the same - value defaults to "auto" currently. Fixed all occurences in docs/comments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds
deferparameter to tool definition that allows to configure tool deferral and pre-loading when tool search is activated.