Skip to content

Python: Clarify service session ID scoping - #6993

Merged
giles17 merged 1 commit into
microsoft:mainfrom
eavanvalkenburg:note_on_openai_sessions
Jul 8, 2026
Merged

Python: Clarify service session ID scoping#6993
giles17 merged 1 commit into
microsoft:mainfrom
eavanvalkenburg:note_on_openai_sessions

Conversation

@eavanvalkenburg

@eavanvalkenburg eavanvalkenburg commented Jul 8, 2026

Copy link
Copy Markdown
Member

Motivation & Context

Clarifies user-facing guidance around AgentSession.service_session_id when service-managed history is used. The current docs describe it as a lightweight state field, but do not make the OpenAI API key/project scoping behavior or hosted multi-user responsibility explicit.

This helps library users understand that OpenAI resp_* response IDs and conv_* conversation IDs are scoped to the backing API key/project by default, and that hosted agents using one backing key/project for multiple users should bind stored service-side IDs to authenticated users or tenants before resuming.

Description & Review Guide

  • What are the major changes?
    • Expanded AgentSession and SessionContext docstrings to describe service_session_id as a service-managed session identifier.
    • Added OpenAI session sample guidance to avoid echoing raw service session IDs to clients and accepting them back unscoped in hosted multi-user apps.
  • What is the impact of these changes?
    • Documentation-only clarification; no runtime behavior, API surface, tests, or serialization changes.
  • What do you want reviewers to focus on?
    • Whether the terminology avoids confusing service_session_id with background response continuation tokens.
    • Whether the hosted multi-user OpenAI scoping guidance is accurate and appropriately placed in user-facing docs/sample guidance.

Related Issue

N/A — documentation-only clarification; no linked issue.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 8, 2026 11:32
@giles17 giles17 added the python Usage: [Issues, PRs], Target: Python label Jul 8, 2026
@github-actions github-actions Bot changed the title Clarify service session ID scoping Python: Clarify service session ID scoping Jul 8, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 5 | Confidence: 95% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by eavanvalkenburg's agents

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _sessions.py3963391%112–114, 116–117, 134–135, 137–139, 217–218, 308, 569–573, 622, 628, 662, 733, 737, 747, 887, 903, 1036, 1050–1051, 1074, 1096, 1106, 1148
TOTAL44490534687% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
8815 33 💤 0 ❌ 0 🔥 2m 11s ⏱️

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves user guidance around service_session_id by clarifying that it may represent a provider-issued, service-side continuation handle and by adding multi-user/tenant safety notes to the OpenAI sample.

Changes:

  • Add hosted multi-user guidance in the OpenAI session continuation sample to discourage unscoped client round-tripping of service_session_id.
  • Refine core session docstrings to better describe what service_session_id represents and how it should be treated.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
python/samples/02-agents/providers/openai/client_with_session.py Adds cautionary guidance for hosted multi-user apps when persisting/round-tripping service_session_id.
python/packages/core/agent_framework/_sessions.py Updates SessionContext/AgentSession docstrings to clarify semantics of service_session_id.

Comment thread python/packages/core/agent_framework/_sessions.py
Comment thread python/packages/core/agent_framework/_sessions.py
Comment thread python/packages/core/agent_framework/_sessions.py
@giles17
giles17 added this pull request to the merge queue Jul 8, 2026
Merged via the queue into microsoft:main with commit c64f8d9 Jul 8, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants