mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Addressed additional properties metadata in the conversion fallback.
This commit is contained in:
+47
@@ -616,6 +616,53 @@ public sealed class DefaultMcpToolHandlerTests
|
||||
uriContent.MediaType.Should().Be("application/octet-stream");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertContentBlock_ResourceLinkBlock_WithMeta_ShouldPropagateToAdditionalProperties()
|
||||
{
|
||||
// Arrange
|
||||
ResourceLinkBlock block = new()
|
||||
{
|
||||
Uri = "https://example.com/resource.bin",
|
||||
Name = string.Empty,
|
||||
MimeType = "application/zip",
|
||||
Meta = new System.Text.Json.Nodes.JsonObject
|
||||
{
|
||||
["traceId"] = "abc-123",
|
||||
["priority"] = 7,
|
||||
},
|
||||
};
|
||||
|
||||
// Act
|
||||
AIContent result = DefaultMcpToolHandler.ConvertContentBlock(block);
|
||||
|
||||
// Assert
|
||||
UriContent uriContent = result.Should().BeOfType<UriContent>().Subject;
|
||||
uriContent.AdditionalProperties.Should().NotBeNull();
|
||||
uriContent.AdditionalProperties!.Should().HaveCount(2);
|
||||
uriContent.AdditionalProperties["traceId"].Should().BeSameAs(block.Meta!["traceId"]);
|
||||
uriContent.AdditionalProperties["priority"].Should().BeSameAs(block.Meta["priority"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertContentBlock_ResourceLinkBlock_WithName_ShouldMapNameToFilenameAdditionalProperty()
|
||||
{
|
||||
// Arrange
|
||||
ResourceLinkBlock block = new()
|
||||
{
|
||||
Uri = "https://example.com/resource.bin",
|
||||
Name = "resource.bin",
|
||||
MimeType = "application/zip",
|
||||
};
|
||||
|
||||
// Act
|
||||
AIContent result = DefaultMcpToolHandler.ConvertContentBlock(block);
|
||||
|
||||
// Assert
|
||||
UriContent uriContent = result.Should().BeOfType<UriContent>().Subject;
|
||||
uriContent.AdditionalProperties.Should().NotBeNull();
|
||||
uriContent.AdditionalProperties!["filename"].Should().Be("resource.bin");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertContentBlock_ToolUseContentBlock_ShouldReturnFunctionCallContent()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user