How should an Agent expose an underlying IChatClient without Agent middleware? #7877
How should an Agent expose an underlying IChatClient without Agent middleware?I would like to discuss whether an This is useful for host-side tasks that are related to the current agent session but should not run as part of the agent loop. A common example is generating a short conversation title for the current agent session. Today, That makes it awkward to reuse the agent's model client for auxiliary host work:
Would it make sense to expose a clearer API for this scenario? For example: IChatClient rawClient = agent.GetBaseChatClient();or, if this should only apply to IChatClient rawClient = chatClientAgent.InnerChatClient;
IChatClient pipelineClient = chatClientAgent.ChatClient;The exact shape is not important. The important distinction is that there are two different use cases:
Having an explicit API would make these scenarios easier to implement without depending on middleware ordering or private construction details. |
Replies: 2 comments
|
westey (@westey-m) Roger Barreto (@rogerbarreto) would appreciate your thoughts on this API shape, since it affects |
|
1448376744 (@soul-soft), thanks for the question. The problem with requiring ChatClientAgent to expose the leaf ChatClient is that it doesn't necessarily have access to this either. When using Even with I believe that the only option that will work reliably is option 4 from your list: Aside: Do note that if you know the type of the leaf ChatClient (e.g. |
1448376744 (@soul-soft), thanks for the question.
The problem with requiring ChatClientAgent to expose the leaf ChatClient is that it doesn't necessarily have access to this either. When using
UseProvidedChatClientAsIs = true, the expectation is that the developer would have built a custom stack, which would include decorators for Function Invocation and potentially many more. In this case ChatClientAgent faces the same issue as you are describing.Even with
UseProvidedChatClientAsIs = truethe ChatClient provided may not be a leaf node. It could already be decorated or be a ChatClient that switches between other chat clients.I believe that the only option that will work reliably is opti…