Skip to content

Add opaque metadata passthrough to SDK tool definitions#1864

Open
belaltaher8 wants to merge 1 commit into
github:mainfrom
belaltaher8:belaltaher8/tool-meta-passthrough
Open

Add opaque metadata passthrough to SDK tool definitions#1864
belaltaher8 wants to merge 1 commit into
github:mainfrom
belaltaher8:belaltaher8/tool-meta-passthrough

Conversation

@belaltaher8

@belaltaher8 belaltaher8 commented Jul 1, 2026

Copy link
Copy Markdown

Add an optional _metadata`` bag to the Tooldefinition (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.

Comment thread nodejs/src/types.ts Outdated
@belaltaher8 belaltaher8 force-pushed the belaltaher8/tool-meta-passthrough branch from 500bb3d to 68c607d Compare July 8, 2026 00:57
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>
@belaltaher8 belaltaher8 force-pushed the belaltaher8/tool-meta-passthrough branch from 68c607d to 6fdc349 Compare July 8, 2026 01:04
@belaltaher8 belaltaher8 changed the title Add opaque _meta passthrough to SDK tool definitions Add opaque metadata passthrough to SDK tool definitions Jul 8, 2026
@belaltaher8 belaltaher8 requested a review from stephentoub July 8, 2026 01:28
@belaltaher8 belaltaher8 marked this pull request as ready for review July 8, 2026 01:54
@belaltaher8 belaltaher8 requested a review from a team as a code owner July 8, 2026 01:54
Copilot AI review requested due to automatic review settings July 8, 2026 01:54

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

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 metadata to tool definition types/builders (Rust/Go/Node/Python/.NET/Java) with “omit when unset” behavior where applicable.
  • Wire metadata through 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
*/
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