Skip to content

azure-ai-agentserver-responses sessions not being created when sending requests from azure functions #46846

@mhmtkcm

Description

@mhmtkcm

  • Package Name: azure-ai-projects / agent-framework-foundry-hosting / azure-ai-agentserver-responses
  • Package Version: 2.1.0 / 1.0.0a260507 / 1.0.0b5
  • Python Version: 3.13.13

Describe the bug

When sending requests to a Foundry-hosted agent (via the azure-ai-projects OpenAI client) from within an Azure Function, sessions are not visible on the Foundry-hosted agent side.

  • Application Insights traces show that a microsoft.session.id is generated internally on invoke_agent spans, but the session never appears in the Foundry portal.
  • Even when I explicitly create a session manually using beta.agents.create_session, the session still does not show up in the Foundry portal.
  • Running the exact same code locally (using FoundryAgent, openai_client, or raw HTTP) works fine — sessions are created and visible as expected.

This raises a concern: if sessions are not properly registered when requests come from Azure Functions, independent invocations may be sharing context unintentionally, which could lead to data leakage between unrelated requests.

To Reproduce

  1. From an Azure Function, send a request to a Foundry-hosted agent using azure-ai-projects (OpenAI client / responses API).
  2. Check the Foundry portal — no session appears.
  3. Try manually creating a session via beta.agents.create_session — still not visible.
  4. Run the same code locally — sessions are created and visible normally.

Expected behavior

  • Sessions should be created and visible in the Foundry portal regardless of whether the request originates from a local environment or an Azure Function.
  • Each Function invocation should be properly isolated to avoid context leakage between requests.

Additional context

  • Issue only occurs when the code runs inside an Azure Function; identical code works locally.
  • Authentication: Managed Identity, AzureCliCredential
  • Main concern: potential cross-request context bleeding between independent Function invocations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI ProjectsService AttentionWorkflow: This issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions