Skip to content

Python: [Bug]: Duplicate arguments in declaration-only function call when streamed #6973

Description

@cecheta

Description

When streaming an agent with a declaration-only tool, the arguments of the function call are duplicated when looking at the message contents.

Code Sample

import asyncio

from agent_framework import Agent, FunctionTool
from agent_framework.foundry import FoundryChatClient
from azure.identity import AzureCliCredential
from pydantic import BaseModel, Field


class WeatherInput(BaseModel):
    location: str = Field(description="The location to get the weather for.")


async def main() -> None:
    client = FoundryChatClient(
        credential=AzureCliCredential(),
    )

    agent = Agent(
        client=client,
        name="WeatherAgent",
        instructions="You are a helpful weather agent. Use the get_weather tool to answer questions.",
        tools=[
            FunctionTool(
                name="get_weather", description="Get the weather for a given location.", input_model=WeatherInput
            )
        ],
    )

    response_stream = agent.run("What's the weather like in Seattle?", stream=True)
    outputs = await response_stream.get_final_response()

    print(outputs.messages[0].contents[0].arguments)  # {"location":"Seattle"}{"location":"Seattle"}


if __name__ == "__main__":
    asyncio.run(main())

Error Messages / Stack Traces

Package Versions

agent-framework-core: 1.10.0, agent-framework-foundry: 1.10.0

Python Version

Python 3.13.13

Additional Context

No response

Metadata

Metadata

Labels

agentsUsage: [Issues, PRs], Target: Single agentpythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow

Type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions