Skip to content

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

Closed

Description

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

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Jul 7, 2026
  2. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Jul 7, 2026
  3. github-actions commented on Jul 7, 2026

    @github-actions
    Contributor

    🤖 Automated triage reproduction notes (agent-authored — trust but verify)

    Agent analysis

    Repro: FunctionInvocationLayer._stream() in packages/core/agent_framework/_tools.py (around line 2821) re-yields function_call contents that were already yielded from the inner stream (line 2774), causing _process_update in _types.py (line 1910) to concatenate arguments via +=. The fix should prevent the duplicate yield of function_call contents for declaration-only tools in the streaming path — either by not yielding the extra update when the results are already function_call type, or by not including function_call items in result["function_call_results"] at line 2379. Minimal repro: create a MockBaseChatClient with FunctionInvocationLayer, set streaming_responses with function_call chunks for a declaration-only FunctionTool, call get_response(stream=True), and check final_response arguments.

    • Failing test: python/packages/core/tests/core/test_declaration_only_streaming_duplication.py
    • Files examined: packages/core/agent_framework/_tools.py, packages/core/agent_framework/_types.py, packages/core/tests/core/test_function_invocation_logic.py, packages/core/tests/core/conftest.py
    • Tests run: packages/core/tests/core/test_declaration_only_streaming_duplication.py::test_declaration_only_tool_streaming_no_argument_duplication, packages/core/tests/core/test_declaration_only_streaming_duplication.py::test_declaration_only_tool_streaming_single_chunk_no_duplication
    • Reported version: 1.10.0
    • Current version: 1.10.0
  4. added
    agentsUsage: [Issues, PRs], Target: Single agent
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions