diff --git a/python/packages/core/agent_framework/_agents.py b/python/packages/core/agent_framework/_agents.py index 0125adb188..9feed96708 100644 --- a/python/packages/core/agent_framework/_agents.py +++ b/python/packages/core/agent_framework/_agents.py @@ -587,9 +587,11 @@ def __init__( name: str | None = None, description: str | None = None, chat_message_store_factory: Callable[[], ChatMessageStoreProtocol] | None = None, - conversation_id: str | None = None, context_providers: ContextProvider | list[ContextProvider] | AggregateContextProvider | None = None, middleware: Middleware | list[Middleware] | None = None, + # chat option params + allow_multiple_tool_calls: bool | None = None, + conversation_id: str | None = None, frequency_penalty: float | None = None, logit_bias: dict[str | int, float] | None = None, max_tokens: int | None = None, @@ -630,10 +632,11 @@ def __init__( description: A brief description of the agent's purpose. chat_message_store_factory: Factory function to create an instance of ChatMessageStoreProtocol. If not provided, the default in-memory store will be used. - conversation_id: The conversation ID for service-managed threads. - Cannot be used together with chat_message_store_factory. context_providers: The collection of multiple context providers to include during agent invocation. middleware: List of middleware to intercept agent and function invocations. + allow_multiple_tool_calls: Whether to allow multiple tool calls in a single response. + conversation_id: The conversation ID for service-managed threads. + Cannot be used together with chat_message_store_factory. frequency_penalty: The frequency penalty to use. logit_bias: The logit bias to use. max_tokens: The maximum number of tokens to generate. @@ -688,6 +691,7 @@ def __init__( agent_tools = [tool for tool in normalized_tools if not isinstance(tool, MCPTool)] self.chat_options = ChatOptions( model_id=model_id, + allow_multiple_tool_calls=allow_multiple_tool_calls, conversation_id=conversation_id, frequency_penalty=frequency_penalty, instructions=instructions, @@ -758,6 +762,7 @@ async def run( messages: str | ChatMessage | list[str] | list[ChatMessage] | None = None, *, thread: AgentThread | None = None, + allow_multiple_tool_calls: bool | None = None, frequency_penalty: float | None = None, logit_bias: dict[str | int, float] | None = None, max_tokens: int | None = None, @@ -793,6 +798,7 @@ async def run( Keyword Args: thread: The thread to use for the agent. + allow_multiple_tool_calls: Whether to allow multiple tool calls in a single response. frequency_penalty: The frequency penalty to use. logit_bias: The logit bias to use. max_tokens: The maximum number of tokens to generate. @@ -844,6 +850,7 @@ async def run( co = run_chat_options & ChatOptions( model_id=model_id, conversation_id=thread.service_thread_id, + allow_multiple_tool_calls=allow_multiple_tool_calls, frequency_penalty=frequency_penalty, logit_bias=logit_bias, max_tokens=max_tokens, @@ -887,6 +894,7 @@ async def run_stream( messages: str | ChatMessage | list[str] | list[ChatMessage] | None = None, *, thread: AgentThread | None = None, + allow_multiple_tool_calls: bool | None = None, frequency_penalty: float | None = None, logit_bias: dict[str | int, float] | None = None, max_tokens: int | None = None, @@ -922,6 +930,7 @@ async def run_stream( Keyword Args: thread: The thread to use for the agent. + allow_multiple_tool_calls: Whether to allow multiple tool calls in a single response. frequency_penalty: The frequency penalty to use. logit_bias: The logit bias to use. max_tokens: The maximum number of tokens to generate. @@ -971,6 +980,7 @@ async def run_stream( co = run_chat_options & ChatOptions( conversation_id=thread.service_thread_id, + allow_multiple_tool_calls=allow_multiple_tool_calls, frequency_penalty=frequency_penalty, logit_bias=logit_bias, max_tokens=max_tokens, diff --git a/python/packages/core/agent_framework/_clients.py b/python/packages/core/agent_framework/_clients.py index 3cac845ed3..ffef28d1e2 100644 --- a/python/packages/core/agent_framework/_clients.py +++ b/python/packages/core/agent_framework/_clients.py @@ -722,6 +722,8 @@ def create_agent( chat_message_store_factory: Callable[[], ChatMessageStoreProtocol] | None = None, context_providers: ContextProvider | list[ContextProvider] | AggregateContextProvider | None = None, middleware: Middleware | list[Middleware] | None = None, + allow_multiple_tool_calls: bool | None = None, + conversation_id: str | None = None, frequency_penalty: float | None = None, logit_bias: dict[str | int, float] | None = None, max_tokens: int | None = None, @@ -759,6 +761,8 @@ def create_agent( If not provided, the default in-memory store will be used. context_providers: Context providers to include during agent invocation. middleware: List of middleware to intercept agent and function invocations. + allow_multiple_tool_calls: Whether to allow multiple tool calls per agent turn. + conversation_id: The conversation ID to associate with the agent's messages. frequency_penalty: The frequency penalty to use. logit_bias: The logit bias to use. max_tokens: The maximum number of tokens to generate. @@ -809,6 +813,8 @@ def create_agent( chat_message_store_factory=chat_message_store_factory, context_providers=context_providers, middleware=middleware, + allow_multiple_tool_calls=allow_multiple_tool_calls, + conversation_id=conversation_id, frequency_penalty=frequency_penalty, logit_bias=logit_bias, max_tokens=max_tokens,