Repository navigation
Fix notetaking Responses samples losing notes on new hosted sessions - #1039
Merged
Hui Miao (huimiu) merged 1 commit intoOct 13, 2026
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
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
JeffreyCA
marked this pull request as ready for review
October 12, 2026 23:54
JeffreyCA
requested review from
Ankit Sinha (ankitbko) and
Hui Miao (huimiu)
as code owners
October 12, 2026 23:54
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Both implementations correctly address the missing request-body session ID while preserving local behavior.
0 open findings
What changed in this PR
Fixes note persistence for newly created hosted sessions by using the platform-provided session ID fallback.
Changes:
- Resolves session IDs from request body, environment, then
"default". - Applies equivalent behavior to Python and C# samples.
| File | Description |
|---|---|
main.py |
Adds hosted-session environment fallback. |
Program.cs |
Adds equivalent C# fallback and helper. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
JeffreyCA
had a problem deploying
to
L4-validation
October 13, 2026 05:41 — with
GitHub Actions
Error
JeffreyCA
had a problem deploying
to
L4-validation
October 13, 2026 05:41 — with
GitHub Actions
Failure
Hui Miao (huimiu)
approved these changes
Oct 13, 2026
Hui Miao (huimiu)
merged commit Oct 13, 2026
10383e1
into
microsoft-foundry:main
35 of 39 checks passed
This branch had an error being 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 PR fixes the Python and C# notetaking Responses samples so notes saved on a fresh hosted session land in that session instead of a shared
"default"file.Issue
azd ai agent invoke --new-sessiondoesn't sendagent_session_idin the request body for hosted agents. The platform creates the session and returns its ID in thex-agent-session-idheader, and azd saves that ID for the next invoke. Both handlers only read the body field, though, so that first call wrote tonotes_default.jsonl.The next invoke sends the real session ID, so
get_notesreadsnotes_<id>.jsonland comes back empty. Invokes that already had a session ID worked, which is why the bug only shows up after--new-session.This isn't an azd regression. azd has left the body field empty for new remote sessions since
/invocationssupport was added. The Python agentserver SDK resolves the session ID as the body field, thenFOUNDRY_AGENT_SESSION_ID, then a derived value. The samples skipped the middle step. The .NET SDK reads the same variable.Fix
Both handlers now resolve the session ID in this order:
agent_session_idfrom the request body, used by local runs and explicit callersFOUNDRY_AGENT_SESSION_ID, set by the platform in hosted containers"default", kept for local curl calls that pass no sessionLocal behaviour doesn't change, because
azd ai agent invoke --localalways sends a session ID in the body.Notes still aren't shared across sessions. Each hosted session has its own sandbox and
$HOME, so a note saved in one session won't show up after a second--new-session. That part of the report is by design.Testing
py_compileon the Python sample anddotnet buildon the C# sample.