diff --git a/python/packages/core/agent_framework/_clients.py b/python/packages/core/agent_framework/_clients.py index f0bd051980d..de6b47b0a37 100644 --- a/python/packages/core/agent_framework/_clients.py +++ b/python/packages/core/agent_framework/_clients.py @@ -29,10 +29,7 @@ from ._docstrings import apply_layered_docstring from ._serialization import SerializationMixin -from ._tools import ( - FunctionInvocationConfiguration, - ToolTypes, -) +from ._tools import ToolTypes from ._types import ( ChatResponse, ChatResponseUpdate, @@ -580,7 +577,6 @@ def as_agent( context_providers: Sequence[Any] | None = None, middleware: Sequence[MiddlewareTypes] | None = None, require_per_service_call_history_persistence: bool = False, - function_invocation_configuration: FunctionInvocationConfiguration | None = None, compaction_strategy: CompactionStrategy | None = None, tokenizer: TokenizerProtocol | None = None, additional_properties: Mapping[str, Any] | None = None, @@ -611,7 +607,6 @@ def as_agent( service-managed conversation is the source of truth (persistence still happens after each model call). When no HistoryProvider is present, this flag has no effect (no middleware is installed and nothing is persisted). - function_invocation_configuration: Optional function invocation configuration override. compaction_strategy: Optional agent-level compaction override. When omitted, client-level compaction defaults remain in effect for each call. tokenizer: Optional agent-level tokenizer override. When omitted, @@ -656,8 +651,6 @@ def as_agent( "tokenizer": tokenizer, "additional_properties": dict(additional_properties) if additional_properties is not None else None, } - if function_invocation_configuration is not None: - agent_kwargs["function_invocation_configuration"] = function_invocation_configuration return Agent(**agent_kwargs) diff --git a/python/packages/core/tests/core/test_clients.py b/python/packages/core/tests/core/test_clients.py index ac110a4a173..397e75d192e 100644 --- a/python/packages/core/tests/core/test_clients.py +++ b/python/packages/core/tests/core/test_clients.py @@ -62,6 +62,16 @@ def test_base_client_as_agent_uses_explicit_additional_properties(chat_client_ba assert agent.additional_properties == {"team": "core"} +def test_base_client_as_agent_rejects_function_invocation_configuration( + chat_client_base: SupportsChatGetResponse, +) -> None: + with pytest.raises( + TypeError, + match=r"as_agent\(\) got an unexpected keyword argument 'function_invocation_configuration'", + ): + chat_client_base.as_agent(function_invocation_configuration={"enabled": False}) + + async def test_base_client_get_response_uses_explicit_client_kwargs(chat_client_base: SupportsChatGetResponse) -> None: async def fake_inner_get_response(**kwargs): assert kwargs["trace_id"] == "trace-123" diff --git a/python/samples/02-agents/a2a/a2a_agent_as_function_tools.py b/python/samples/02-agents/a2a/a2a_agent_as_function_tools.py index c441fe77e17..745cb569f08 100644 --- a/python/samples/02-agents/a2a/a2a_agent_as_function_tools.py +++ b/python/samples/02-agents/a2a/a2a_agent_as_function_tools.py @@ -6,6 +6,7 @@ import httpx from a2a.client import A2ACardResolver +from agent_framework import Agent from agent_framework.a2a import A2AAgent from agent_framework.foundry import FoundryChatClient from azure.identity import AzureCliCredential @@ -86,7 +87,8 @@ async def main() -> None: model=model, credential=credential, ) - host_agent = client.as_agent( + host_agent = Agent( + client=client, name="assistant", instructions="You are a helpful assistant. Use your tools to answer questions.", tools=skill_tools,