Skip to content

Python: [Bug]: server_error on client.agents.create_version() for hosted agent — SDK v2.1.0 / agent-framework 1.2.2 #5570

@mitokic

Description

@mitokic

Description

Calling AIProjectClient.agents.create_version() to deploy a hosted agent consistently returns an HTTP 500 server_error with no actionable details. The error persists across retries and different SDK configurations. The container image is valid, pushed to ACR, and the agent previously deployed successfully on the older SDK stack.

Code Sample

from azure.identity import DefaultAzureCredential
from azure.ai.projects import AIProjectClient
from azure.ai.projects.models import (
    HostedAgentDefinition,
    ProtocolVersionRecord,
    AgentProtocol,
)

client = AIProjectClient(
    endpoint="<FOUNDRY_PROJECT_ENDPOINT>",
    credential=DefaultAzureCredential(),
    allow_preview=True,
)

agent = client.agents.create_version(
    agent_name="agent-name",
    definition=HostedAgentDefinition(
        container_protocol_versions=[
            ProtocolVersionRecord(
                protocol=AgentProtocol.RESPONSES,
                version="1.0.0",
            )
        ],
        cpu="1",
        memory="2Gi",
        image="<ACR>.azurecr.io/<IMAGE>:<TAG>",
        environment_variables={...},  # 16 env vars
        tools=[
            {
                "type": "mcp",
                "server_label": "WorkIQUser",
                "project_connection_id": "<MCP_CONNECTION_ID>",
            }
        ],
    ),
)

Error Messages / Stack Traces

HttpResponseError: (server_error) An error occurred while processing your request.
You can retry your request, or contact us if the error persists.
Code: server_error

Package Versions

SDK: azure-ai-projects==2.1.0, agent-framework==1.2.2, agent-framework-foundry-hosting==1.0.0a260429

Python Version

Python 3.12

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions