Skip to content

Python: Allow branching from hosted Foundry conversations - #7526

Open
cecheta wants to merge 3 commits into
microsoft:mainfrom
cecheta:response-branching
Open

Python: Allow branching from hosted Foundry conversations#7526
cecheta wants to merge 3 commits into
microsoft:mainfrom
cecheta:response-branching

Conversation

@cecheta

@cecheta cecheta commented Aug 5, 2026

Copy link
Copy Markdown
Member

Motivation & Context

Allow branching from previous response in a conversation, by always storing state for response ID, plus conversation if applicable.

Description & Review Guide

  • What are the major changes?
  • What is the impact of these changes?
  • What do you want reviewers to focus on?

State is now always stored under the response ID. If a conversation is supplied:

  • For normal agents, state is also stored under the conversation
  • For workflow agents, state is copied from the response ID state to the conversation ID state

Related Issue

Fixes #7524

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.

Copilot AI lite review requested due to automatic review settings August 5, 2026 10:36
@cecheta
cecheta temporarily deployed to github-app-auth August 5, 2026 10:36 — with GitHub Actions Inactive
@cecheta
cecheta temporarily deployed to github-app-auth August 5, 2026 10:36 — with GitHub Actions Inactive
@cecheta
cecheta temporarily deployed to github-app-auth August 5, 2026 10:36 — with GitHub Actions Inactive
@cecheta
cecheta temporarily deployed to github-app-auth August 5, 2026 10:37 — with GitHub Actions Inactive
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/foundry_hosting/agent_framework_foundry_hosting
   _responses.py9429390%199–202, 270, 275, 299, 354–355, 369, 372–373, 405–406, 440, 456, 518, 643, 657, 707, 767, 770, 776, 778, 850, 931, 933, 974–975, 1093, 1323, 1336, 1827–1829, 1831, 1878–1879, 1881–1882, 1884–1885, 1887–1888, 1893, 1902, 1905–1907, 1909, 1919, 1923, 1936, 2027–2028, 2043–2044, 2046, 2051–2055, 2057, 2064–2065, 2067–2068, 2074, 2076–2080, 2087, 2093, 2115, 2121, 2127, 2129, 2131–2134, 2142, 2144, 2205–2207, 2221–2222, 2225–2226
   _session_store.py260100% 
TOTAL44687410690% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
9135 34 💤 0 ❌ 0 🔥 2m 3s ⏱️

@cecheta
cecheta temporarily deployed to github-app-auth August 5, 2026 10:40 — with GitHub Actions Inactive

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 updates the Python Foundry Hosting integration to support conversation branching by ensuring every Responses turn persists state under its immutable response_id, while conversations also maintain a conversation_id latest-state alias for continuation.

Changes:

  • Persist regular-agent session snapshots under every response_id, and additionally update the conversation_id snapshot as a “latest turn” alias when a conversation is supplied.
  • For workflow agents, write checkpoints per-turn under response_id and update a conversation_id checkpoint alias to the latest checkpoint after each conversation turn.
  • Add/extend tests to validate branching behavior for both regular agents and workflow agents (streaming and non-streaming), and update Foundry Hosting docs to reflect the new persistence model.
Show a summary per file
File Description
python/packages/foundry_hosting/tests/test_responses.py Adds branching-focused tests for both session snapshots and workflow checkpoints (including streaming).
python/packages/foundry_hosting/README.md Documents the new model: always store under response_id plus a conversation_id latest-state alias.
python/packages/foundry_hosting/agent_framework_foundry_hosting/_session_store.py Updates Foundry session store docstring to describe response-first storage plus conversation aliasing.
python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py Implements response-id-first persistence for sessions and checkpoints; introduces workflow checkpoint finalization to update conversation aliases.

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

@cecheta
cecheta temporarily deployed to github-app-auth August 5, 2026 11:02 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Feature]: Foundry Hosting - Support conversation branching

2 participants