Problem
ToolResponse has a Metadata field (string) that is stored in ToolResultContent.ClientMetadata. However, when toResponseMessages converts ToolResultContent → ToolResultPart for the conversation message round-trip, ClientMetadata is dropped.
This means downstream consumers (agent harnesses, session persistence layers) cannot access tool-level metadata from the step history. Any data a tool wants to carry through the message pipeline for display reconstruction (diffs, file metadata, etc.) is lost once the tool result becomes a message.
Proposal
A ClientMetadata field should be added to ToolResultPart, and copied from ToolResultContent.ClientMetadata in toResponseMessages. This should be a non-breaking additive change — the field should be omitempty and default to the zero value.
Changes
ToolResultPart.ClientMetadata string (json: client_metadata,omitempty)
toResponseMessages copies from ToolResultContent.ClientMetadata
- JSON marshal/unmarshal in
content_json.go should include the new field
Use case
A tool computes display-oriented data (e.g. a diff of file changes) that should be available when the session is replayed from stored messages, without including that data in the LLM conversation context (which stays in Output).
Problem
ToolResponsehas aMetadatafield (string) that is stored inToolResultContent.ClientMetadata. However, whentoResponseMessagesconvertsToolResultContent→ToolResultPartfor the conversation message round-trip,ClientMetadatais dropped.This means downstream consumers (agent harnesses, session persistence layers) cannot access tool-level metadata from the step history. Any data a tool wants to carry through the message pipeline for display reconstruction (diffs, file metadata, etc.) is lost once the tool result becomes a message.
Proposal
A
ClientMetadatafield should be added toToolResultPart, and copied fromToolResultContent.ClientMetadataintoResponseMessages. This should be a non-breaking additive change — the field should beomitemptyand default to the zero value.Changes
ToolResultPart.ClientMetadata string(json:client_metadata,omitempty)toResponseMessagescopies fromToolResultContent.ClientMetadatacontent_json.goshould include the new fieldUse case
A tool computes display-oriented data (e.g. a diff of file changes) that should be available when the session is replayed from stored messages, without including that data in the LLM conversation context (which stays in
Output).