Python: skip Foundry session persist after a failed conversation turn - #7637
Open
Shikhar Goel (sgoel2be24-cyber) wants to merge 4 commits into
Open
Conversation
… turn Saving the mutated session on failure poisons later requests that reuse the same conversation_id. Non-conversation runs still persist on failure.
Shikhar Goel (sgoel2be24-cyber)
deployed
to
github-app-auth
August 13, 2026 03:55 — with
GitHub Actions
Active
Shikhar Goel (sgoel2be24-cyber)
deployed
to
github-app-auth
August 13, 2026 03:55 — with
GitHub Actions
Active
Shikhar Goel (sgoel2be24-cyber)
deployed
to
github-app-auth
August 13, 2026 03:55 — with
GitHub Actions
Active
Shikhar Goel (sgoel2be24-cyber)
deployed
to
github-app-auth
August 13, 2026 03:55 — with
GitHub Actions
Active
Author
|
@microsoft-github-policy-service agree |
Shikhar Goel (sgoel2be24-cyber)
deployed
to
github-app-auth
August 13, 2026 05:38 — with
GitHub Actions
Active
Member
|
Unfortunately this doesn't fix the issue, as the problem is that the messages get saved to the chat history, not the session. |
Skip persisting input items when a stored response is failed so the next request on the same conversation does not replay the bad turn.
Shikhar Goel (sgoel2be24-cyber)
deployed
to
github-app-auth
August 13, 2026 11:06 — with
GitHub Actions
Active
Author
|
You're right — the first commit skipped the wrong store. The agentserver response provider was persisting input items for failed turns, so the next request on the same conversation replayed them via chat history (get_history()), not the MAF session. 24ebe8b wraps the response store so failed turns persist without input items (including the in_progress → failed update path). A follow-up request on the same conversation no longer sees the bad function_call_output. Tests cover both the store wrapper and the HTTP conversation repro from the issue. |
Shikhar Goel (sgoel2be24-cyber)
deployed
to
github-app-auth
August 13, 2026 16:53 — with
GitHub Actions
Active
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
When a hosted Foundry agent is used with
conversation_id, a failed request still saved the mutated Agent Framework session. The next request on the same conversation then replayed the bad input and failed too. Azure OpenAI does not keep failed input on the conversation.Fixes #7630
Description & Review Guide
_handle_inner_agent, skipsession_storage.setwhen the request failed andcontext.conversation_idis set. Non-conversation runs still persist on failure (existingtest_failed_run_still_saves_mutated_session).previous_response_id/ anonymous sessions.Related Issue
Fixes #7630
Contribution Checklist
Assistance: drafted with an AI coding agent and reviewed before opening.
Made with Cursor