-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Open
Labels
customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.Workflow: This is a new issue that needs to be triaged to the appropriate team.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
Description
Service traces for request: https://dataexplorer.azure.com/dashboards/0b69c942-b3cd-4303-a087-96902864f967?p-_startTime=2days&p-_endTime=now&p-p_apim_request_id=v-cee89311-a325-47bf-b336-008837622037&p-p_take=v-1000#47505622-afa0-403f-a39e-d5c67eade5ea
Steps to repro
Make sure you
- azd ai agent init https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/agent-framework/agent-with-foundry-tools/agent.yaml
- Update the version of the azure-ai-agentserver-agentframework to 1.0.0.b15
- azd env set enableHostedAgentVNext=true
- Set an environment variable AZURE_OPENAI_CHAT_DEPLOYMENT_NAME, it wasn't picked up from the YAML
- use the below yaml and main.py
here is the error message
azd ai agent invoke "search the web for weather in roanoke, va"
Agent: af-agent-with-foundry-tools (remote)
Message: "search the web for weather in roanoke, va"
Session: 7aabdff5-5b92-4f91-9c4c-b00010c4b897
Conversation: conv_a3b64d25f700f00200hMjSNHCcLlScCP0YPoHlB1SLWj2UfT55
Trace ID: cee89311-a325-47bf-b336-008837622037
ERROR: agent error (server_error): <class 'agent_framework.azure._chat_client.AzureOpenAIChatClient'> service failed to complete the prompt: Error code: 400 - {'error': {'message': "Invalid 'messages[6].tool_calls[0].id': string too long. Expected a string with maximum length 40, but got a string with length 55 instead.", 'type': 'invalid_request_error', 'param': 'messages[6].tool_calls[0].id', 'code': 'string_above_max_length'}}here is the main.py
import os
from dotenv import load_dotenv
from agent_framework.azure import AzureOpenAIChatClient
from azure.ai.agentserver.agentframework import from_agent_framework, FoundryToolsChatMiddleware
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
# Load environment variables from .env file for local development
# load_dotenv()
# Create a token provider that refreshes tokens automatically for long-running servers
# This avoids 401 errors when the initial token expires (typically after 1 hour)
_credential = DefaultAzureCredential()
_token_provider = get_bearer_token_provider(_credential, "https://cognitiveservices.azure.com/.default")
def main():
required_env_vars = [
"AZURE_OPENAI_ENDPOINT",
"AZURE_OPENAI_CHAT_DEPLOYMENT_NAME",
"AZURE_AI_PROJECT_ENDPOINT",
]
for env_var in required_env_vars:
assert env_var in os.environ and os.environ[env_var], (
f"{env_var} environment variable must be set."
)
tools=[{"type": "web_search"}]
if project_tool_connection_id := os.environ.get("AZURE_AI_PROJECT_TOOL_CONNECTION_ID"):
tools.append({"type": "mcp", "project_connection_id": project_tool_connection_id})
# Use token provider for automatic token refresh in long-running servers
chat_client = AzureOpenAIChatClient(ad_token_provider=_token_provider,
middleware=FoundryToolsChatMiddleware(tools))
agent = chat_client.create_agent(
name="FoundryToolAgent",
instructions="You are a helpful assistant with access to various tools."
)
from_agent_framework(agent).run()
if __name__ == "__main__":
main()Here is the agent.yaml
kind: hosted
name: af-agent-with-foundry-tools
description: |
An AI agent that uses Azure OpenAI with a Hosted Model Context Protocol (MCP) server. The agent answers questions by searching Microsoft Learn documentation using MCP tools.
metadata:
authors:
- Microsoft
tags:
- Azure AI AgentServer
- Microsoft Agent Framework
- Model Context Protocol
- MCP
protocols:
- protocol: responses
version: ""
environment_variables:
- name: AZURE_OPENAI_ENDPOINT
value: ${AZURE_OPENAI_ENDPOINT}
- name: AZURE_OPENAI_CHAT_DEPLOYMENT_NAME
value: gpt-5
- name: AZURE_AI_PROJECT_ENDPOINT
value: ${AZURE_AI_PROJECT_ENDPOINT}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
customer-reportedIssues that are reported by GitHub users external to the Azure organization.Issues that are reported by GitHub users external to the Azure organization.needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.Workflow: This is a new issue that needs to be triaged to the appropriate team.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that