You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 15e885d
Browse filesBrowse the repository at this point in the historyBrowse files
Add McpClientTool.WithResultMarshaling to let hosts control InvokeAsync results
McpClientTool.InvokeCoreAsync applies a fixed marshaling policy: content
blocks become AIContent when the result carries nothing else, and otherwise
the entire CallToolResult is serialized to a JsonElement. Because the
returned value is what IChatClient pipelines surface to the AI model, that
policy makes consequential decisions on the host's behalf: any application
_meta key (e.g. a correlation id intended for the host) flips a plain text
result into a JSON envelope handed to the model with the _meta included;
isError results reach the model as textual JSON rather than the provider's
native error signaling; and results carrying both content and
structuredContent are forwarded in duplicate. Hosts currently have no way
to opt out short of abandoning McpClientTool for a hand-rolled AIFunction.
Add WithResultMarshaling(Func<CallToolResult, CancellationToken,
ValueTask<object?>>), following the existing With* clone pattern. When
supplied, the delegate receives the raw CallToolResult and fully replaces
the built-in conversion, giving hosts exact control over what is surfaced
to consumers. It plays the same role for tool results that
AIFunctionFactoryOptions.MarshalResult plays for factory-created functions.
Default behavior is unchanged.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0 commit comments