Skip to content

feat: add ClientMetadata to ToolResultPart #257

@carsonfarmer

Description

@carsonfarmer

Problem

ToolResponse has a Metadata field (string) that is stored in ToolResultContent.ClientMetadata. However, when toResponseMessages converts ToolResultContentToolResultPart 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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions