Repository navigation
.NET: [Feature]: AIAgent.AsIChatClient #3496
Description
Activity
- added.NETUsage: [Issues, PRs], Target: .NetUsage: [Issues, PRs], Target: .Net
on Jan 29, 2026 - changed the title
[-][Feature]: AIAgent.AsIChatClient[/-][+].NET: [Feature]: AIAgent.AsIChatClient[/+]on Jan 29, 2026 shyamnamboodiripad commented
on Jan 29, 2026 More actionsOne use case where this would be helpful is for the
Microsoft.Extensions.AI.Evaluationframework which defines .NET abstractions for (AI) evaluation along with a set of in-built evaluators. These abstractions currently rely onIChatClientfor all AI / LLM interactions. It would be great to have the ability to leverage agents (e.g., Copilot SDK) to perform these evaluations the same way one would otherwise use an LLM (with or without tools).(You can read more about the above framework and the functionality it supports in this blog post.)
tomas-rampas commented
on Aug 16, 2026 ContributorMore actionsI'd like to take this on, as described below — happy to adjust the shape based on maintainer feedback.
Proposed API, mirroring the existing
AsAIFunction(this AIAgent, ..., AgentSession?)extension and the M.E.AIAsIChatClientnaming convention already used across this repo:// Microsoft.Agents.AI / AIAgentExtensions public static IChatClient AsIChatClient(this AIAgent agent, AgentSession? session = null)
Backed by an internal
AIAgentChatClient : IChatClientthat:- maps
GetResponseAsync/GetStreamingResponseAsynctoRunAsync/RunStreamingAsync, reusing the existingAsChatResponse()/AsChatResponseUpdatesAsync()converters; - carries
ChatOptionsthroughChatClientAgentRunOptions(soChatClientAgenthonors temperature/tools/instructions/ConversationId), additionally copyingResponseFormatonto the baseAgentRunOptionsso structured output (GetResponseAsync<T>) works for every agent type; - defaults to stateless per call (full history each request); the optional bound session mirrors
AsAIFunctionsemantics; - forwards
GetServiceto the agent, synthesizingChatClientMetadatafromAIAgentMetadataas fallback;Disposeis a no-op (the caller owns the agent lifetime).
Unit tests (no live LLM) covering argument guards, options/session pass-through, raw
ChatResponse/ConversationIdpreservation, streaming conversion,GetService, and an end-to-endChatClientAgent+ structured-output case. PR to follow shortly.- maps
- added a commit that references this issue
on Sep 16, 2026
There are more and more APIs across the .NET ecosystem now accepting IChatClient. It'd be helpful if any AIAgent could be used as an IChatClient, at least for basic operations.
cc: westey (@westey-m)