Skip to content

Python: [Bug]: The as_agent method of BaseChatClient accepts a function_invocation_configuration parameter, but Agent no longer agrees with that. #4985

Closed

Description

@qtalen

Description

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'

Package Versions

agent-framework==1.0.0rc6; agent-framework-openai==1.0.0rc6

Python Version

Python 3.13.7

Additional Context

No response

Activity

  1. added
    bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)
    on Mar 31, 2026
  2. eavanvalkenburg commented on Apr 7, 2026

    @eavanvalkenburg
    Member

    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"] = 8
    
    agent = client.as_agent(
        name="Code Assistant",
        instructions="You are a helpful assistant.",
    )

    We'll fix the as_agent() method. See the function_invocation_configuration sample for the recommended pattern.

  3. removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)pythonUsage: [Issues, PRs], Target: Python

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions