Python: Preserve message status in chat history XML - #14453
Open
Gali (Jokasa7) wants to merge 2 commits into
Open
Gali (Jokasa7) wants to merge 2 commits into
Gali (Jokasa7) wants to merge 2 commits into
Conversation
Gali (Jokasa7)
had a problem deploying
to
github-app-auth
September 17, 2026 09:17 — with
GitHub Actions
Failure
Gali (Jokasa7)
had a problem deploying
to
github-app-auth
September 17, 2026 09:17 — with
GitHub Actions
Failure
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Explicitly setting an optional status to None can cause XML serialization to fail instead of omitting the attribute.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR preserves ChatMessageContent.status values during chat history XML serialization.
Changes:
- Adds
statusto XML message attributes. - Adds round-trip tests for all status values and serialization entry points.
File summaries
| File | Summary |
|---|---|
python/tests/unit/contents/test_chat_history.py |
Tests status XML round trips. |
python/semantic_kernel/contents/chat_message_content.py |
Serializes message status attributes. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| root = Element(self.tag) | ||
| for field in self.model_fields_set: | ||
| if field not in ["role", "name", "encoding", "finish_reason", "ai_model_id"]: | ||
| if field not in ["role", "name", "encoding", "finish_reason", "status", "ai_model_id"]: |
Gali (Jokasa7)
had a problem deploying
to
github-app-auth
September 17, 2026 09:26 — with
GitHub Actions
Failure
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 and Context
Python
ChatMessageContent.statusrecords the Responses API message state, butChatHistory.to_prompt()/str(history)omits that field from the XML message attributes. Loading the rendered prompt therefore silently changes every explicit status (completed,failed,in_progress, orincomplete) toNone.Description
Include the existing optional
statusfield inChatMessageContent.to_element()'s XML attribute allowlist. The existing enum handling writes its string value, andChatMessageContent.from_element()already validates that value back intoStatus. Legacy XML without a status attribute continues to deserialize withstatus=None.Regression tests cover all four
Statusvalues through both public ChatHistory XML serialization entry points. They also verify that clearing an optional status after construction omits the XML attribute instead of passingNoneto ElementTree.Validation
TypeError: cannot serialize Nonebefore the follow-up guard.pytest tests/unit/contents -q: 404 passed, with existing deprecation warnings.uv-lock, and Bandit.Contribution Checklist
statusretains its existing behavior.Prepared with AI assistance, including the implementation, tests, and this description. The behavior was reproduced and validated locally without a live provider request.