mirror of
https://github.com/microsoft/autogen.git
synced 2025-07-22 08:21:44 +00:00

## Summary Implements the `tool_choice` parameter for `ChatCompletionClient` interface as requested in #6696. This allows users to restrict which tools the model can choose from when multiple tools are available. ## Changes ### Core Interface - Core Interface: Added `tool_choice: Tool | Literal["auto", "required", "none"] = "auto"` parameter to `ChatCompletionClient.create()` and `create_stream()` methods - Model Implementations: Updated client implementations to support the new parameter, for now, only the following model clients are supported: - OpenAI - Anthropic - Azure AI - Ollama - `LlamaCppChatCompletionClient` currently not supported Features - "auto" (default): Let the model choose whether to use tools, when there is no tool, it has no effect. - "required": Force the model to use at least one tool - "none": Disable tool usage completely - Tool object: Force the model to use a specific tool --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>