Skip to content

FunctionInvokingChatClient should respect ChatOptions.Tools modifications by function tool #7217

@westey-m

Description

@westey-m

FunctionInvokingChatClient provides a FunctionInvocationContext that contains ChatOptions when invoking function tools.

If one of the executed functions modifies the Tools list on ChatOptions, this updated set of tools will be advertised to the downstream ChatClient. However, FunctionInvokingChatClient does not respect these updates when invoking subsequent functions, which can cause failures. FunctionInvokingChatClient currently caches a dictionary of tool name to tool, which is calculated at the start of the function loop, and before any modifications might happen.

Here is a step by step workflow explaining how a failure may happen:

  1. FICC is called, and it calls the downstream ChatClient.
  2. FICC gets a FCC back and FICC calls the appropriate Function tool (lets say Function A)
  3. Function A modifies ChatOptions.Tools on FunctionInvocationContext by adding Function B to the list.
  4. FICC calls the downstream ChatClient.
  5. FICC gets a FCC back for Function B.
  6. FICC fails to invoke Function B, saying that it cannot find Function B

Also see microsoft/agent-framework#3083

Metadata

Metadata

Labels

area-aiMicrosoft.Extensions.AI libraries

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions