Skip to content

Python: [Bug]: No tool output found for function call #5041

@TaoChenOSU

Description

@TaoChenOSU

Description

Agent invocation results in error when chained.

Code Sample

# Copyright (c) Microsoft. All rights reserved.

import asyncio
import os

from agent_framework import Agent, tool
from agent_framework.foundry import FoundryChatClient
from azure.identity import AzureCliCredential
from dotenv import load_dotenv

load_dotenv()


@tool(approval_mode="never_require")
def query_data(
    topic: str,
) -> str:
    """Query internal data about a topic."""
    print(f"  [query_data] topic={topic}")
    return f"Data from default: Revenue for {topic} is $10M."


@tool(approval_mode="never_require")
def get_style(format: str = "plain") -> str:
    """Get the output formatting style."""
    print(f"  [get_style] format={format}")
    return f"Use {format} formatting with bullet points."


async def main() -> None:
    client = FoundryChatClient(
        project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
        model=os.environ["FOUNDRY_MODEL"],
        credential=AzureCliCredential(),
    )

    agent_a = Agent(
        client=client,
        name="researcher",
        instructions="Call query_data exactly once with the user's topic. Return the raw result.",
        tools=[query_data],
    )

    agent_b = Agent(
        client=client,
        name="writer",
        instructions="Call get_style exactly once, then rewrite the data as a short report.",
        tools=[get_style],
    )

    response = await agent_a.run("Summarize Q3 revenue.")
    response = await agent_b.run(["Summarize Q3 revenue.", *response.messages])

    return


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

Error Messages / Stack Traces

ERROR: ... service failed to complete the prompt: Error code: 400 -
    {'error': {'message': 'No tool output found for function call <call_id>.',
    'type': 'invalid_request_error', 'param': 'input', 'code': None}}

Package Versions

agent-framework

Python Version

Python 3.12

Additional Context

No response

Metadata

Metadata

Labels

bugSomething isn't workingpythonv1.0Features being tracked for the version 1.0 GA

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions