Repository navigation
Fix notetaking Responses samples losing notes on new hosted sessions - #1067
Closed
Hui Miao (huimiu) wants to merge 2 commits into
Closed
Hui Miao (huimiu) wants to merge 2 commits into
Hui Miao (huimiu) wants to merge 2 commits into
Conversation
When a hosted invoke omits agent_session_id from the request body, fall back to the platform-supplied FOUNDRY_AGENT_SESSION_ID before the shared "default" key, so notes are keyed to the session that actually runs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5669b012-ea21-4939-93f9-ea72266b7852
Hui Miao (huimiu)
requested a review
from Ankit Sinha (ankitbko)
as a code owner
October 13, 2026 03:16
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Both implementations consistently apply the documented fallback order without introducing unresolved issues.
0 open findings
What changed in this PR
Fixes session-scoped note persistence when hosted Responses requests omit the session ID from the body.
Changes:
- Falls back to
FOUNDRY_AGENT_SESSION_IDin Python and C#. - Preserves body-provided IDs and the local
"default"fallback.
| File | Description |
|---|---|
samples/python/.../main.py |
Adds hosted environment session-ID fallback. |
samples/csharp/.../Program.cs |
Adds equivalent session-ID resolution for .NET. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch was successfully deployed
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.
Fixes #1038
This re-submits the fix proposed in #1039 on a branch in
microsoft-foundry/foundry-samples.When a hosted Responses agent starts a new session, the platform provides the session ID through
FOUNDRY_AGENT_SESSION_ID; the request body may not containagent_session_id. The Python and C# handlers now resolve IDs in this order:agent_session_idfrom the request bodyFOUNDRY_AGENT_SESSION_IDfrom the hosted environment"default"fallbackThis keeps the initial note write and later reads on the same session-specific file while preserving local and direct-call behavior.
Validation:
dotnet buildpassed with 0 warnings and 0 errors.