Azure / Azure/azure-sdk-for-python
`azure-ai-agentserver-responses` sessions not being created when sending requests from azure functions
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 3.4k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 193
Description
---
- **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.
Contributor guide
Assessment
This issue has not been assessed yet.