Skip to content

[Agents] ChatCompletionAgent.InvokeAsync<T> — expose IChatClient structured output through the agent layer #7498

@ericstj

Description

@ericstj

Problem

IChatClient (M.E.AI preview) supports GetResponseAsync<T>() for structured output via JSON schema. ChatCompletionAgent in SK 1.45 doesn't surface this, so developers who want typed responses from a named agent must bypass the agent abstraction entirely.

This creates a choice: use M.E.AI IChatClient directly (typed output, no agent identity) or use SK ChatCompletionAgent (agent identity, no typed output). Symphony and similar orchestration patterns need both.

Proposed API

var pow = await agent.InvokeAsync<ProofOfWork>(prompt);
// where ProofOfWork is a [JSonSerializable] C# record

Cross-provider coverage

  • OpenAI: response_format: json_schema
  • Azure OpenAI: same ✅
  • Google Gemini: response_schema
  • Anthropic Claude: tool-use workaround ⚠️

Reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-aiMicrosoft.Extensions.AI librariesenhancementThis issue represents an ask for new feature or an enhancement to an existing oneuntriaged

    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