Skip to content

ToolResultSerializer

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework

ToolResultSerializer Class

Shared utility for converting tool result objects to a string representation suitable for display or inclusion in chat messages. Handles the System.Text.Json.JsonElement values produced by MEAI's AIFunctionFactory, plain strings, and arbitrary objects.

public static class ToolResultSerializer

Inheritance System.Object 🡒 ToolResultSerializer

Methods

ToolResultSerializer.Serialize(object) Method

Serializes a tool result for inclusion in a Microsoft.Extensions.AI.FunctionResultContent or for display. System.Text.Json.JsonElement values are rendered to raw JSON text. Strings are returned as-is. Null returns empty string. All other types are JSON-serialized.

public static string Serialize(object? result);

Parameters

result System.Object

Returns

System.String