Skip to content

.NET Microsoft.Agents.AI.A2A A2AClient does not support tool invocation #1150

@tommasodotNET

Description

@tommasodotNET

I have an agent with tools, I'm exposing the agent via

app.MapA2A("document-management-agent", "/agenta2a", new AgentCard
{
    Name = agent!.Name!,
    Url = "http://localhost:5196/agenta2a",
    Description = "Document Management and Policy Compliance Assistant",
    Version = "1.0",
    DefaultInputModes = ["text"],
    DefaultOutputModes = ["text"],
    Capabilities = new AgentCapabilities
    {
        Streaming = true,
        PushNotifications = false
    },
    Skills = [
        new AgentSkill
        {
            Name = "Document Search",
            Description = "Search and retrieve company documents, policies, and procedures",
            Examples = ["Find the remote work policy", "What is the purchase approval process?", "Show me the latest HR policies"]
        },
        new AgentSkill
        {
            Name = "Content Extraction",
            Description = "Extract and analyze content from PDF, Word, and PowerPoint documents",
            Examples = ["Extract text from this PDF", "Analyze the content of this Word document"]
        },
        new AgentSkill
        {
            Name = "Compliance Lookup",
            Description = "Check compliance requirements for various operations and spending levels",
            Examples = ["What are the compliance requirements for a $10,000 purchase?", "List the safety compliance rules"]
        },
        new AgentSkill
        {
            Name = "Document Management",
            Description = "Provide document version information and management",
            Examples = ["What is the latest version of the employee handbook?", "Manage document versions"]
        }
    ]

});

using Microsoft.Agents.AI.Hosting.A2A.AspNetCore.

When the client connect to that agent using

builder.AddAIAgent("document-management-agent", (sp, key) =>
{
    var httpClient = new HttpClient()
    {
        BaseAddress = new Uri(Environment.GetEnvironmentVariable("services__dotnetagent__https__0") ?? Environment.GetEnvironmentVariable("services__dotnetagent__http__0")!),
        Timeout = TimeSpan.FromSeconds(60)
    };
    var agentCardResolver = new A2ACardResolver(httpClient.BaseAddress!, httpClient, agentCardPath: "/agenta2a/v1/card");

    return agentCardResolver.GetAIAgentAsync().GetAwaiter().GetResult();
});

and I try to invoke the agent, I'll get a deserialization error during agent.RunAsync.

The agent on the server is defined as

builder
    .AddAIAgent("document-management-agent", (sp, key) =>
    {
        var instrumentedChatClient = sp.GetRequiredService<IChatClient>();

        var documentTools = sp.GetRequiredService<DocumentTools>().GetFunctions();

        var agent = new ChatClientAgent(instrumentedChatClient,
                name: key,
                instructions: @"You are a specialized Document Management and Policy Compliance Assistant. Your role is to help users find company policies, procedures, compliance requirements, and manage document-related tasks.

Your capabilities include:
- Searching and retrieving company documents, policies, and procedures
- Extracting and analyzing content from PDF, Word, and PowerPoint documents
- Looking up specific policies by category (HR, Safety, Finance, IT, etc.)
- Checking compliance requirements for various operations and spending levels
- Providing document version information and management
- Indexing and organizing documents from various sources

When users ask about policies, always provide specific requirements, proce  dures, and any exceptions that apply. For compliance questions, clearly explain what approvals are needed and any additional requirements. Be helpful and thorough in your responses while maintaining accuracy based on the available document data.

Sample areas you can help with:
- Remote work policies and procedures
- Safety requirements and procedures
- Purchase authorization and approval processes
- HR policies and employee handbook information
- Compliance rules and requirements
- Document version management
- Contract and legal document information",
                tools: [.. documentTools,
                AIFunctionFactory.Create(DocumentProcessingTools.ExtractPdfText),
                AIFunctionFactory.Create(DocumentProcessingTools.ParseOfficeDocument),
                AIFunctionFactory.Create(DocumentProcessingTools.IndexDocuments)]);

        return agent;
    });

and when I remove the tools part, it works.

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions