Description
When running a declarative workflow through AG-UI, InvokeAzureAgent fails with:
TypeError: Agent.run() got an unexpected keyword argument '_raw_function_invocation_kwargs'
What happened
agent-framework-ag-ui calls workflow.run(function_invocation_kwargs={"forwarded_props": ...}).
agent-framework-core stores both the resolved kwargs and the original payload under the internal state key _raw_function_invocation_kwargs (intended for nested WorkflowExecutor remapping).
agent-framework-declarative InvokeAzureAgent reads the entire WORKFLOW_RUN_KWARGS bag and does await agent.run(..., **run_kwargs), which forwards _raw_function_invocation_kwargs as a real keyword argument.
Agent.run() only accepts the public name function_invocation_kwargs (no **kwargs), so it raises TypeError.
What we expected
_raw_function_invocation_kwargs / _raw_client_kwargs should stay internal to the workflow state (for nested workflow routing). Declarative agent invocation should only pass public Agent.run parameters (e.g. function_invocation_kwargs, client_kwargs, session, tools, …), typically via the already-populated options["additional_function_arguments"] path.
Steps to reproduce
- Install current PyPI latest:
agent-framework-core==1.18.0, agent-framework-declarative==1.0.4, agent-framework-ag-ui==1.3.0.
- Build a declarative workflow with an
InvokeAzureAgent action (no tools required on the agent).
- Run it through the AG-UI workflow host (so
function_invocation_kwargs={"forwarded_props": ...} is passed).
- Observe the
TypeError on the first agent step.
Code Sample
Relevant declarative path (installed 1.0.4):
# agent_framework_declarative/.../_executors_agents.py
run_kwargs: dict[str, Any] = ctx.get_state(WORKFLOW_RUN_KWARGS_KEY, {})
if run_kwargs:
options = dict(run_kwargs.get("options") or {})
options["additional_function_arguments"] = run_kwargs
run_kwargs = {k: v for k, v in run_kwargs.items() if k != "options"}
result = await agent.run(messages_for_agent, options=options, **run_kwargs)
# ^^^^^^^^^^
# includes "_raw_function_invocation_kwargs" when AG-UI forwarded nested props
Core stores the raw key when values are mappings (AG-UI always does):
# agent_framework/_workflows/_workflow.py (1.18.0)
if function_invocation_kwargs is not None:
combined_kwargs["function_invocation_kwargs"] = self._resolve_invocation_kwargs(...)
if isinstance(function_invocation_kwargs, WorkflowInvocationKwargs) or any(
isinstance(value, Mapping) for value in function_invocation_kwargs.values()
):
combined_kwargs[RAW_FUNCTION_INVOCATION_KWARGS_KEY] = function_invocation_kwargs
AG-UI trigger:
# agent_framework_ag_ui/_workflow_run.py (1.3.0)
fwd_kwargs["function_invocation_kwargs"] = {"forwarded_props": forwarded_props}
Suggested fix (declarative): before calling Agent.run, remap/drop internal keys:
if "_raw_function_invocation_kwargs" in run_kwargs:
run_kwargs.setdefault(
"function_invocation_kwargs",
run_kwargs.pop("_raw_function_invocation_kwargs"),
)
run_kwargs.pop("_raw_function_invocation_kwargs", None)
# similarly for _raw_client_kwargs → client_kwargs
allowed = {
"session", "middleware", "tools", "options", "compaction_strategy",
"tokenizer", "function_invocation_kwargs", "client_kwargs", "stream",
}
run_kwargs = {k: v for k, v in run_kwargs.items() if k in allowed}
Error Messages / Stack Traces
TypeError: Agent.run() got an unexpected keyword argument '_raw_function_invocation_kwargs'
File ".../agent_framework_declarative/_workflows/_executors_agents.py", in _invoke_agent_and_store_results
result: Any = await agent.run(messages_for_agent, options=options, **run_kwargs)
File ".../agent_framework_declarative/_workflows/_executors_agents.py", in handle_action
raise AgentInvalidResponseException(
f"Agent '{agent_name}' invocation failed: {e}"
)
Package Versions
agent-framework-core: 1.18.0, agent-framework-declarative: 1.0.4, agent-framework-ag-ui: 1.3.0 (PyPI latest as of 2026-09-16)
Python Version
Python 3.12
Additional Context
- This is reproducible with a minimal declarative graph:
Foreach → InvokeMcpTool → InvokeAzureAgent (agent has no tools). Failure happens at InvokeAzureAgent even when MCP succeeds.
- Orchestration / direct
Agent.run paths that inject kwargs via middleware are unaffected; the failure is specific to declarative reading WORKFLOW_RUN_KWARGS and splatting internal _raw_* keys.
- Confirmed packages are already at PyPI latest; this is a cross-package contract bug, not an outdated dependency.
Description
When running a declarative workflow through AG-UI,
InvokeAzureAgentfails with:What happened
agent-framework-ag-uicallsworkflow.run(function_invocation_kwargs={"forwarded_props": ...}).agent-framework-corestores both the resolved kwargs and the original payload under the internal state key_raw_function_invocation_kwargs(intended for nestedWorkflowExecutorremapping).agent-framework-declarativeInvokeAzureAgentreads the entireWORKFLOW_RUN_KWARGSbag and doesawait agent.run(..., **run_kwargs), which forwards_raw_function_invocation_kwargsas a real keyword argument.Agent.run()only accepts the public namefunction_invocation_kwargs(no**kwargs), so it raisesTypeError.What we expected
_raw_function_invocation_kwargs/_raw_client_kwargsshould stay internal to the workflow state (for nested workflow routing). Declarative agent invocation should only pass publicAgent.runparameters (e.g.function_invocation_kwargs,client_kwargs,session,tools, …), typically via the already-populatedoptions["additional_function_arguments"]path.Steps to reproduce
agent-framework-core==1.18.0,agent-framework-declarative==1.0.4,agent-framework-ag-ui==1.3.0.InvokeAzureAgentaction (no tools required on the agent).function_invocation_kwargs={"forwarded_props": ...}is passed).TypeErroron the first agent step.Code Sample
Relevant declarative path (installed
1.0.4):Core stores the raw key when values are mappings (AG-UI always does):
AG-UI trigger:
Suggested fix (declarative): before calling
Agent.run, remap/drop internal keys:Error Messages / Stack Traces
Package Versions
agent-framework-core: 1.18.0, agent-framework-declarative: 1.0.4, agent-framework-ag-ui: 1.3.0 (PyPI latest as of 2026-09-16)
Python Version
Python 3.12
Additional Context
Foreach→InvokeMcpTool→InvokeAzureAgent(agent has no tools). Failure happens atInvokeAzureAgenteven when MCP succeeds.Agent.runpaths that inject kwargs via middleware are unaffected; the failure is specific to declarative readingWORKFLOW_RUN_KWARGSand splatting internal_raw_*keys.