Azure / Azure/azure-sdk-for-python

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

Aperta
#46,846 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug customer-reported Hosted Agents needs-team-attention Service Attention
Lingua principale
Python
Stelle
5.6k
Fork
3.4k
Merge medio
2g 2h
PR unite (30g)
213

Descrizione

---

- **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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il percorso della richiesta all'interno di una Azure Function con il azure-ai-projects OpenAI client e la responses API, quindi confrontalo con il caso locale funzionante. Verifica se beta.agents.create_session, FoundryAgent e raw HTTP producono un comportamento diverso delle sessioni nell'ambiente della Function. Il lavoro è completato quando le sessioni compaiono nel Foundry portal e le invocazioni separate della Function rimangono isolate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
azure, python
Ambito
backend, cloud
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.