-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
Description
Description
Just discovered a new flag that controls whether chat history is stored locally or remotely: STORE_BY_DEFAULT. Some clients have this set to True: https://github.com/microsoft/agent-framework/blob/main/python/packages/core/agent_framework/openai/_responses_client.py#L250
However, it looks like there is a bug where if store=False is passed the agent that uses one of these clients, neither a local nor a remote storage is set up for the agent: https://github.com/microsoft/agent-framework/blob/main/python/packages/core/agent_framework/_agents.py#L1041
Code Sample
# Copyright (c) Microsoft. All rights reserved.
import asyncio
import os
from typing import Annotated, Any
from agent_framework import AgentSession, Message, tool
from agent_framework.azure import AzureOpenAIResponsesClient
from azure.identity import AzureCliCredential
from dotenv import load_dotenv
from pydantic import Field
# Load environment variables from .env file
load_dotenv()
@tool(approval_mode="always_require")
async def get_weather(
location: Annotated[str, Field(description="The location to get the weather for.")],
**kwargs: Any,
) -> str:
"""Get the weather for a given location."""
# Get session object from kwargs
session = kwargs.get("session")
if session and isinstance(session, AgentSession) and session.service_session_id:
print(f"Session ID: {session.service_session_id}.")
return f"The weather in {location} is cloudy."
async def main() -> None:
client = AzureOpenAIResponsesClient(
project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
deployment_name=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
credential=AzureCliCredential(),
)
agent = client.as_agent(
name="WeatherAgent",
instructions="You are a helpful weather assistant.",
tools=[get_weather],
default_options={"store": False},
)
session = agent.create_session()
result = await agent.run("What is the weather in London?", session=session)
while len(result.user_input_requests) > 0:
approvals: list[Message] = []
for user_input_needed in result.user_input_requests:
print(
f"\nUser Input Request for function from {agent.name}:"
f"\n Function: {user_input_needed.function_call.name}"
f"\n Arguments: {user_input_needed.function_call.arguments}"
)
# Add the user's approval response
approvals.append(Message("user", [user_input_needed.to_function_approval_response(approved=True)]))
# Run again with all the context
result = await agent.run(approvals, session=session)
if result.text:
print(f"\nAgent response: {result.text}")
if __name__ == "__main__":
asyncio.run(main())Error Messages / Stack Traces
agent_framework.exceptions.ChatClientException: <class 'agent_framework.azure._responses_client.AzureOpenAIResponsesClient'> service failed to complete the prompt: Error code: 400 - {'error': {'message': 'No tool call found for function call output with call_id call_vkdrwm8sXNDMP2xsnZRFJx7H.', 'type': 'invalid_request_error', 'param': 'input', 'code': None}}Package Versions
agent-framework
Python Version
3.10
Additional Context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status