encodeResultToParts

open fun encodeResultToParts(result: TResult, serializer: JSONSerializer): List<MessagePart.ContentPart>(source)

Encodes the given result as a list of MessagePart.ContentPart to be sent to the LLM.

Override this to return non-text content (images, files, etc.) alongside or instead of the default text representation. The default wraps encodeResultToString in a single MessagePart.Text.

Note: not all LLM providers support non-text content in tool results. Clients will log a warning and fall back gracefully when an unsupported part type is encountered.

Return

A list of content parts representing the tool result.

Parameters

result

The result returned by execute.

serializer

The JSON serializer available for encoding structured data.