Description
File: python/packages/core/agent_framework/_clients.py — BaseChatClient.as_agent()
Description:
BaseChatClient.as_agent() accepts a function_invocation_configuration parameter and forwards it into Agent(**agent_kwargs). However, Agent.__init__() (in _agents.py) does not accept this keyword argument, causing a TypeError at runtime whenever function_invocation_configuration is provided.
TypeError: Agent.__init__() got an unexpected keyword argument 'function_invocation_configuration'
Root cause:
function_invocation_configuration is consumed by FunctionInvocationLayer, which is in the client's MRO (OpenAIChatCompletionClient → FunctionInvocationLayer → ...), not in the Agent's MRO (Agent → AgentMiddlewareLayer → AgentTelemetryLayer → RawAgent → BaseAgent → ...).
Lines 86-87 of as_agent() conditionally add it to agent_kwargs, and line 89 passes it to Agent():
if function_invocation_configuration is not None:
agent_kwargs["function_invocation_configuration"] = function_invocation_configuration
return Agent(**agent_kwargs)
Since Agent.__init__ has no **kwargs and no function_invocation_configuration parameter, this always raises TypeError.
Reproduction:
from agent_framework import FunctionInvocationConfiguration
from agent_framework.openai import OpenAIChatCompletionClient
client = OpenAIChatCompletionClient(model="gpt-4o", api_key="test")
# This raises TypeError
agent = client.as_agent(
name="test",
instructions="You are helpful.",
function_invocation_configuration=FunctionInvocationConfiguration(
include_detailed_errors=True,
),
)
Expected behavior:
as_agent() should either apply function_invocation_configuration to the client before creating the Agent (since it's a client-level concern), or Agent.__init__ should accept and forward it appropriately.
Workaround:
Set function_invocation_configuration at client construction time instead:
client = OpenAIChatCompletionClient(
model="gpt-4o",
api_key="test",
function_invocation_configuration=FunctionInvocationConfiguration(
include_detailed_errors=True,
),
)
agent = client.as_agent(name="test", instructions="You are helpful.")
Code Sample
Error Messages / Stack Traces
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[3], [line 6](vscode-notebook-cell:?execution_count=3&line=6)
2 from agent_framework.openai import OpenAIChatCompletionClient
3
4
5 # This raises TypeError
----> [6](vscode-notebook-cell:?execution_count=3&line=6) agent = client.as_agent(
7 name="test",
8 instructions="You are helpful.",
9 function_invocation_configuration=FunctionInvocationConfiguration(
File ...\agent_framework\_clients.py:652, in BaseChatClient.as_agent(self, id, name, description, instructions, tools, default_options, context_providers, middleware, require_per_service_call_history_persistence, function_invocation_configuration, compaction_strategy, tokenizer, additional_properties)
649 if function_invocation_configuration is not None:
650 agent_kwargs["function_invocation_configuration"] = function_invocation_configuration
--> [652](file:///.../agent_framework/_clients.py:652) return Agent(**agent_kwargs)
TypeError: Agent.__init__() got an unexpected keyword argument 'function_invocation_configuration'
Package Versions
agent-framework-core: 1.0.0
Python Version
Python 3.14
Additional Context
No response
Description
File:
python/packages/core/agent_framework/_clients.py—BaseChatClient.as_agent()Description:
BaseChatClient.as_agent()accepts afunction_invocation_configurationparameter and forwards it intoAgent(**agent_kwargs). However,Agent.__init__()(in_agents.py) does not accept this keyword argument, causing aTypeErrorat runtime wheneverfunction_invocation_configurationis provided.Root cause:
function_invocation_configurationis consumed byFunctionInvocationLayer, which is in the client's MRO (OpenAIChatCompletionClient→FunctionInvocationLayer→ ...), not in the Agent's MRO (Agent→AgentMiddlewareLayer→AgentTelemetryLayer→RawAgent→BaseAgent→ ...).Lines 86-87 of
as_agent()conditionally add it toagent_kwargs, and line 89 passes it toAgent():Since
Agent.__init__has no**kwargsand nofunction_invocation_configurationparameter, this always raisesTypeError.Reproduction:
Expected behavior:
as_agent()should either applyfunction_invocation_configurationto the client before creating the Agent (since it's a client-level concern), orAgent.__init__should accept and forward it appropriately.Workaround:
Set
function_invocation_configurationat client construction time instead:Code Sample
Error Messages / Stack Traces
Package Versions
agent-framework-core: 1.0.0
Python Version
Python 3.14
Additional Context
No response