Repository navigation
fix: ChatHistory: preserve empty tool results with tool_call_id - #14480
Open
Wu Shuwen (dajiaohuang) wants to merge 1 commit into
Open
Wu Shuwen (dajiaohuang) wants to merge 1 commit into
Wu Shuwen (dajiaohuang) wants to merge 1 commit into
Conversation
_prepare_for_add() checked 'content' (truthy check) when deciding to
create FunctionResultContent for a TOOL message. An empty string content
is falsy, so add_tool_message('', tool_call_id='...') silently dropped
the tool_call_id and created an invalid message with no items.
Change 'content' to 'content is not None' so an empty string result
is accepted and the FunctionResultContent is created with the call_id.
Fixes microsoft#14359.
Wu Shuwen (dajiaohuang)
had a problem deploying
to
github-app-auth
September 25, 2026 08:11 — with
GitHub Actions
Failure
Wu Shuwen (dajiaohuang)
had a problem deploying
to
github-app-auth
September 25, 2026 08:11 — with
GitHub Actions
Failure
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Add the requested regression test for empty tool results and serialization.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Fixes ChatHistory so empty-string tool results preserve their tool_call_id and serialize correctly.
Changes:
- Accepts non-
Nonetool content, including empty strings. - Preserves
FunctionResultContentfor empty tool results.
| File | Summary |
|---|---|
python/semantic_kernel/contents/chat_history.py |
Preserves empty tool results and IDs; add a regression test covering empty results and to_dict() serialization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| kwargs["role"] = role | ||
|
|
||
| if role == AuthorRole.TOOL and content and not items: | ||
| if role == AuthorRole.TOOL and content is not None and not items: |
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.

Description
_prepare_for_add() checked 'content' (truthy check) when deciding to create FunctionResultContent for a TOOL message. An empty string content is falsy, so add_tool_message('', tool_call_id='...') silently dropped the tool_call_id and created an invalid message with no items.
Reproduction
Fix
Change 'content' to 'content is not None' so an empty string result is accepted and the FunctionResultContent is created with the call_id preserved.
Fixes #14359.