Add opaque metadata passthrough to SDK tool definitions#1864
Open
belaltaher8 wants to merge 1 commit into
Open
Add opaque metadata passthrough to SDK tool definitions#1864belaltaher8 wants to merge 1 commit into
metadata passthrough to SDK tool definitions#1864belaltaher8 wants to merge 1 commit into
Conversation
stephentoub
reviewed
Jul 1, 2026
500bb3d to
68c607d
Compare
Add an optional, opaque `metadata` bag to tool definitions across all SDK languages and forward it verbatim over the session.create/resume RPC. This lets hosts attach namespaced metadata to tools without expanding the typed public contract; the runtime may recognize specific keys to inform host-specific behavior. Unknown keys are round-tripped untouched. Languages: nodejs (Tool.metadata + defineTool), python (Tool.metadata + define_tool), go (Tool.Metadata), rust (Tool.metadata + with_metadata), java (ToolDefinition.metadata + createWithMetadata), dotnet (CopilotToolOptions.Metadata + wire ToolDefinition.Metadata). Tests added per language for wire/serialization forwarding and omission when unset. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
68c607d to
6fdc349
Compare
metadata passthrough to SDK tool definitions
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an optional, opaque metadata bag to tool definitions across the multi-language SDKs and forwards it verbatim over session.create / session.resume, enabling hosts to attach namespaced, runtime-recognized (but SDK-opaque) attributes without expanding the typed contract.
Changes:
- Add
metadatato tool definition types/builders (Rust/Go/Node/Python/.NET/Java) with “omit when unset” behavior where applicable. - Wire
metadatathrough session create/resume payload construction (Node + Python shown here; others rely on serialization of the definition type). - Add/extend unit tests to validate serialization and omission semantics; update Java annotation-processor fixtures for the new constructor arity.
Show a summary per file
| File | Description |
|---|---|
| rust/src/types.rs | Add Tool.metadata, builder, Debug output, and serialization test. |
| python/copilot/tools.py | Add Tool.metadata + define_tool(..., metadata=...) passthrough. |
| python/copilot/client.py | Include metadata when building tool definitions for create/resume RPCs. |
| python/test_client.py | Add test asserting metadata forwarded on create/resume and omitted when unset. |
| nodejs/src/types.ts | Extend Tool / defineTool types to include optional metadata. |
| nodejs/src/client.ts | Forward tool.metadata into session.create / session.resume payloads. |
| nodejs/test/client.test.ts | Add tests for forwarding and omission of metadata. |
| go/types.go | Add Tool.Metadata with omitempty JSON tag. |
| go/client_test.go | Add serialization tests for tool metadata presence/omission. |
| dotnet/src/CopilotTool.cs | Add MetadataKey + option plumbing into AITool.AdditionalProperties. |
| dotnet/src/Client.cs | Include metadata in internal wire ToolDefinition built from AI function declarations. |
| dotnet/test/Unit/CopilotToolTests.cs | Add unit tests ensuring metadata is set/omitted in additional properties. |
| java/src/main/java/com/github/copilot/rpc/ToolDefinition.java | Add metadata record component + factories + fluent modifier. |
| java/src/main/java/com/github/copilot/tool/CopilotToolProcessor.java | Emit null metadata argument in generated ToolDefinition(...) calls. |
| java/src/test/java/com/github/copilot/ToolDefinitionTest.java | Add serialization tests for metadata presence/omission. |
| java/src/test/java/com/github/copilot/rpc/fixtures/StaticTools$$CopilotToolMeta.java | Update fixture constructor call to include null metadata arg. |
| java/src/test/java/com/github/copilot/rpc/fixtures/StaticInvocationTools$$CopilotToolMeta.java | Update fixture constructor call to include null metadata arg. |
| java/src/test/java/com/github/copilot/rpc/fixtures/SimpleTools$$CopilotToolMeta.java | Update fixture constructor calls to include null metadata arg. |
| java/src/test/java/com/github/copilot/rpc/fixtures/OverrideTools$$CopilotToolMeta.java | Update fixture constructor call to include null metadata arg. |
| java/src/test/java/com/github/copilot/rpc/fixtures/OptionalParamTools$$CopilotToolMeta.java | Update fixture constructor calls to include null metadata arg. |
| java/src/test/java/com/github/copilot/rpc/fixtures/MultiReturnTools$$CopilotToolMeta.java | Update fixture constructor calls to include null metadata arg. |
| java/src/test/java/com/github/copilot/rpc/fixtures/InvocationAwareTools$$CopilotToolMeta.java | Update fixture constructor calls to include null metadata arg. |
| java/src/test/java/com/github/copilot/rpc/fixtures/DefaultValueTools$$CopilotToolMeta.java | Update fixture constructor call to include null metadata arg. |
| java/src/test/java/com/github/copilot/rpc/fixtures/DateTimeTools$$CopilotToolMeta.java | Update fixture constructor call to include null metadata arg. |
| java/src/test/java/com/github/copilot/rpc/fixtures/ArgCoercionTools$$CopilotToolMeta.java | Update fixture constructor call to include null metadata arg. |
| java/src/test/java/com/github/copilot/e2e/ErgonomicTestTools$$CopilotToolMeta.java | Update fixture constructor calls to include null metadata arg. |
Review details
- Files reviewed: 26/26 changed files
- Comments generated: 1
- Review effort level: Low
Comment on lines
+205
to
+206
| * @since 1.0.0 | ||
| */ |
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.
Add an optional
_metadata`` bag to theTooldefinition (anddefineTool`) and forward it verbatim over the session.create/resume RPC. This lets hosts attach namespaced, opaque metadata to tools without expanding the typed public contract; unknown keys are round-tripped untouched.