Skip to content

Python: [Feature]: DevUI doesn't accept function_invocation_kwargs #7344

Description

Description

When an Agent is executed directly with agent.run(..., function_invocation_kwargs=...), tool functions can access those values through FunctionInvocationContext.

When the same agent is served through agent_framework.devui, there is no way to pass values through function_invocation_kwargs. DevUI calls agent.run(...) without forwarding function_invocation_kwargs. As a result, tools that rely on ctx.kwargs[...] fail.

This makes DevUI unusable for agents whose tools depend on request-scoped invocation kwargs.

I have tried to pass the following message through the DevUI chat window, but as expected the tool call failed.

{
    "messages": "Call echo_ctx with value=hello",
    "function_invocation_kwargs":
    {
        "tenantId": "abc123"
    }
}

Code Sample

python
from typing import Annotated
from pydantic import Field
from dotenv import load_dotenv

from agent_framework import Agent, tool, FunctionInvocationContext
from agent_framework.devui import serve
from agent_framework.foundry import FoundryChatClient
from azure.identity import DefaultAzureCredential
import os

load_dotenv()


@tool(name="echo_ctx", description="Reads a value from invocation kwargs")
def echo_ctx(
    value: Annotated[str, Field(description="Any value")],
    ctx: FunctionInvocationContext,
):
    tenant_id = ctx.kwargs["tenantId"]
    return f"tenant={tenant_id}, value={value}"


client = FoundryChatClient(
    project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
    model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
    credential=DefaultAzureCredential(),
)

agent = Agent(
    client=client,
    name="TestAgent",
    instructions="You are a test agent",
    tools=[echo_ctx],
)

serve(entities=[agent], auto_open=False, auth_enabled=False)

Error Messages / Stack Traces

Package Versions

agent-framework-devui :1.0.0b260721

Python Version

Python 3.12.3

Additional Context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    devuiUsage: [Issues, PRs], Target: DevUIpythonUsage: [Issues, PRs], Target: Python

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions