Skip to content

proposal: tool handler should set Content field if nil #391

@jba

Description

@jba

When ToolFor builds a handler, it sets CallToolResult.StructuredContent to the typed output of the handler. It does not touch CallToolResult.Content.

The spec says that tools which set StructuredContent should set a TextContent to the serialized JSON of StructuredContent. We don't do that now because we don't want to overwrite something that the handler has put there. But there's almost no reason not to do it if Content is nil.

The only downside is that we're marshaling StructuredContent twice: once for this, and once when it goes out on the wire. But perhaps we could stash the marshaled bytes and add a custom JSONMarshaler to use them, if we thought that performance warranted it.

Metadata

Metadata

Assignees

Labels

proposalA proposal for an a new API or behavior. See CONTRIBUTING.md.release blockerThis issue blocks the release milestone with which it is associated.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions