Skip to content

Python: Session isolation does not work as expected for workflow-as-agent deployments in App Service / Container Apps #5472

@cs609

Description

@cs609

We are deploying a workflow created with Microsoft Agent Framework as an agent behind an HTTP endpoint on Azure App Service / Azure Container Apps, so multiple users can chat with the same deployed agent.
We are trying to implement per-user session handling based on the documentation and sample below:
• Documentation: https://learn.microsoft.com/en-us/agent-framework/agents/conversations/session?pivots=programming-l…
• Sample: https://github.com/microsoft/agent-framework/blob/main/python/samples/03-workflows/agents/workflow_…
Our goal is that each user has an isolated conversation session, with memory preserved only for that user across messages.
What we tried:

  1. Shared workflow/agent instance for all users
    • We build the workflow once when the App Service starts.
    • That workflow-as-agent instance is shared by all users.
    • When User A starts chatting, we create a session and use that session ID for User A’s subsequent messages.
    • When User B starts chatting, we create a different session ID and use that for User B’s subsequent messages.
    • Expected result: memory should remain isolated per session/user.
    • Actual result: memory appears to be shared across users.
  2. Rebuilding the workflow for every message / every user
    • We create the workflow/agent again for each message or user interaction.
    • We still use the same session ID for the user’s subsequent messages.
    • Expected result: user memory should persist within that session.
    • Actual result: memory is not preserved when the workflow is recreated each time.
    What we need clarification on:
    • What is the correct deployment pattern for workflow-as-agent when serving multiple concurrent users through a single HTTP endpoint?
    • Is the workflow/agent instance supposed to be shared across users, with session state handled internally by session ID?
    • Or should a separate workflow/agent instance be maintained per user/session?
    • If the workflow can be shared, what is the correct way to ensure memory isolation between sessions?
    • If the workflow must not be recreated per request, what object needs to remain alive for session memory to work correctly?
    In short, we are unable to achieve both of the following at the same time:
    • isolated memory per user/session
    • preserved memory across that user’s subsequent messages
    Could you please provide guidance on the recommended architecture for multi-user session handling for workflow-as-agent deployments in a web app / containerized endpoint scenario?

Metadata

Metadata

Assignees

Labels

pythonworkflowsRelated to Workflows in agent-framework

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions