You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: [Bug]: The as_agent method of BaseChatClient accepts a function_invocation_configuration parameter, but Agent no longer agrees with that. #4985
In Python SDK version 1.0.0rc6, if you create an agent like this:
agent=chat_client.as_agent(
name="Code Assistant",
instructions=dedent(""" You are a helpful assistant. """),
function_invocation_configuration=FunctionInvocationConfiguration(
max_iterations=8
),
)
You'll run into this error:
TypeError: Agent.__init__() got an unexpected keyword argument 'function_invocation_configuration'
The reason is that in this version, the as_agent method of BaseChatClient still accepts the function_invocation_configuration parameter, but Agent no longer does.
Code Sample
agent = chat_client.as_agent(
name="Code Assistant",
instructions=dedent("""
You are a helpful assistant.
"""),
function_invocation_configuration=FunctionInvocationConfiguration(
max_iterations=8
),
)
Error Messages / Stack Traces
File "\.venv\Lib\site-packages\agent_framework\_clients.py", line 647, in as_agent
return Agent(**agent_kwargs)
TypeError: Agent.__init__() got an unexpected keyword argument 'function_invocation_configuration'
Thanks for reporting this. You're correct that as_agent() accepts function_invocation_configuration but Agent.__init__() doesn't have that parameter — so it throws a TypeError.
This parameter is a chat-client-level setting that was mistakenly forwarded to the Agent constructor. Even in earlier versions where **kwargs might have swallowed it without an error, the value would have landed in additional_properties rather than actually being applied to the client's function invocation configuration — so it never actually took effect.
The correct approach is to configure the function_invocation_configuration directly on the chat client before calling as_agent():
client=OpenAIChatClient(model_id="gpt-4")
client.function_invocation_configuration["max_iterations"] =8agent=client.as_agent(
name="Code Assistant",
instructions="You are a helpful assistant.",
)
Activity
eavanvalkenburg commentedon Apr 7, 2026
Thanks for reporting this. You're correct that
as_agent()acceptsfunction_invocation_configurationbutAgent.__init__()doesn't have that parameter — so it throws aTypeError.This parameter is a chat-client-level setting that was mistakenly forwarded to the
Agentconstructor. Even in earlier versions where**kwargsmight have swallowed it without an error, the value would have landed inadditional_propertiesrather than actually being applied to the client's function invocation configuration — so it never actually took effect.The correct approach is to configure the
function_invocation_configurationdirectly on the chat client before callingas_agent():We'll fix the
as_agent()method. See the function_invocation_configuration sample for the recommended pattern.