Skip to content

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

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

Activity

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

Metadata

Metadata

Labels

bugUsage: [Issues], Target: all issues (Legacy, prefer issue type: bug)pythonUsage: [Issues, PRs], Target: Python

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions