Python: Fix FHA session ID translation - #7608
Merged
Merged
Conversation
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 21:25 — with
GitHub Actions
Active
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 21:25 — with
GitHub Actions
Active
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 21:25 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
Pull request overview
Separates Foundry hosted-agent session IDs from Responses API continuation IDs so hosted sessions persist across turns.
Changes:
- Persists hosted session IDs in
AgentSession.state. - Propagates provider-specific continuation metadata through streaming and function loops.
- Updates tests, exports, documentation, and the hosted-agent sample.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
python/samples/04-hosting/foundry-hosted-agents/responses/using_deployed_agent.py |
Uses service-created sessions. |
python/packages/foundry/tests/foundry/test_foundry_agent.py |
Tests separate session and continuation IDs. |
python/packages/foundry/README.md |
Documents session persistence. |
python/packages/foundry/agent_framework_foundry/_agent.py |
Implements Foundry session translation. |
python/packages/foundry/agent_framework_foundry/__init__.py |
Exports the session-state key. |
python/packages/core/tests/core/test_foundry_namespace.py |
Tests namespace exposure. |
python/packages/core/agent_framework/foundry/__init__.pyi |
Adds the typed export. |
python/packages/core/agent_framework/foundry/__init__.py |
Adds lazy namespace mapping. |
python/packages/core/agent_framework/_tools.py |
Adds extensible function-loop continuation handling. |
python/packages/core/agent_framework/_agents.py |
Adds extensible session-update hooks. |
docs/specs/004-python-function-calling-loop.md |
Documents the continuation hook. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
Agent Framework Review — Iteration 1
Completed passes: 5 | Result: No high-severity findings
Scope: full PR (1 commit(s)): bbe15c58ef40
Review passes
- Correctness (
gpt-5.6-sol) — No issues found in this pass. - Security Reliability (
claude-opus-4.8) — No issues found in this pass. - Test Coverage (
gpt-5.6-sol) — No issues found in this pass. - Failure Modes (
claude-opus-4.8) — No issues found in this pass. - Design Approach (
claude-opus-4.8) — No issues found in this pass.
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 22:03 — with
GitHub Actions
Active
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 22:42 — with
GitHub Actions
Active
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||||||||||||
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 22:49 — with
GitHub Actions
Active
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 23:10 — with
GitHub Actions
Active
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 23:25 — with
GitHub Actions
Active
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 23:25 — with
GitHub Actions
Active
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 23:25 — with
GitHub Actions
Active
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 23:25 — with
GitHub Actions
Active
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 23:25 — with
GitHub Actions
Active
Tao Chen (TaoChenOSU)
marked this pull request as ready for review
August 10, 2026 23:25
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 23:25 — with
GitHub Actions
Active
Tao Chen (TaoChenOSU)
deployed
to
github-app-auth
August 10, 2026 23:32 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
Agent Framework Review — Iteration 2
Completed passes: 5 | Result: No high-severity findings
Scope: 4 net-new commit(s): aa6afd0d5181, b817149b66e6, fbff74822e4a, 10f44cee0207
Review passes
- Correctness (
gpt-5.6-sol) — No issues found in this pass. - Security Reliability (
claude-opus-4.8) — No issues found in this pass. - Test Coverage (
gpt-5.6-sol) — No issues found in this pass. - Failure Modes (
claude-opus-4.8) — No issues found in this pass. - Design Approach (
claude-opus-4.8) — No issues found in this pass.
Evan Mattson (moonbox3)
deployed
to
github-app-auth
August 11, 2026 04:46 — with
GitHub Actions
Active
Evan Mattson (moonbox3)
approved these changes
Aug 11, 2026
westey (westey-m)
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
Addresses #7503
Previously we were using the Foundry
agent_session_idas the continuation handle of a conversation for Foundry Hosted Agent. That's only partially correct because the Foundryagent_session_idis not an identified of a conversation but rather an identifier of the infrastructure that is running the hosted agent code. To continue a conversation (whether that's via aconversation_idor aprevious_response_id, we first need to send the request to the same Foundry session, which means we have to send both IDs (agent_session_idandconversation_idorprevious_response_id) to continue a conversation.Read more about Foundry's
agent_session_idhere: https://learn.microsoft.com/en-us/azure/foundry/agents/concepts/hosted-agents#isolation-modelDescription & Review Guide
agent_session_idfrom the FHA response and save the id in the state bag of the MAF session.service_session_idwith the FHAagent_session_id. The MAFservice_session_idis supposed to be the continuation handle.isolation_keyas isolation is handled automatically by the platform.agent_session_idis the state bag of the MAF session as part of the request to FHA.FoundryAgentandFoundryChatClientRelated Issue
Fixes #7503
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.