Repository navigation
Python: Respect exclude and exclude_none in BaseChatClient.to_dict for additional_properties - #9943
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits intoNov 4, 2026
Conversation
…ies in BaseChatClient.to_dict Ensure BaseChatClient.to_dict respects exclude and exclude_none parameters when promoting additional_properties to the root level, avoiding leaking excluded fields or None values into serialized dictionaries. Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…nd exclude_none Add unit test coverage verifying that BaseChatClient.to_dict correctly respects exclude_none (omitting None entries by default) and exclude sets (filtering either individual property keys or all additional_properties). Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
Hardik K (hardikkaurani)
requested review from
SergeyMenshykh,
Eduard van Valkenburg (eavanvalkenburg) and
Roger Barreto (rogerbarreto)
as code owners
November 1, 2026 19:17
Hardik K (hardikkaurani)
temporarily deployed
to
github-app-auth
November 1, 2026 19:17 — with
GitHub Actions
Inactive
Hardik K (hardikkaurani)
requested review from
Darren Cohen (dargilco),
Jose Alvarez (jpalvarezl),
sophia-ramsey and
westey (westey-m)
as code owners
November 1, 2026 19:17
Hardik K (hardikkaurani)
temporarily deployed
to
github-app-auth
November 1, 2026 19:17 — with
GitHub Actions
Inactive
Member
|
/review |
Contributor
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (2 commit(s)): 379c6e8cde30, 055be3646bae
Model: gpt-5.6-sol
Overview
The change filters flattened additional_properties against both caller exclusions and exclude_none while retaining the existing serialization flow. The added tests cover default null omission, explicit null preservation, whole-container exclusion, and individual-key exclusion. No Critical, High, or Medium regression introduced by this PR was established.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Nov 4, 2026
This branch was previously 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.
Motivation & Context
In
agent-framework(Python),BaseChatClient.to_dictacceptsexcludeandexclude_none(defaulting toTrue) parameters to control serialization. However,BaseChatClient.to_dictpreviously performedresult.update(self.additional_properties)unconditionally at the end of serialization.Because this update bypassed the serialization parameters:
exclude={"additional_properties"}or specifying a key present inadditional_propertiesfailed to exclude it.Nonevalues inadditional_propertieswere unconditionally added to the output dictionary even whenexclude_none=True(the default).Description & Review Guide
What are the major changes?
BaseChatClient.to_dictto checkexcludebefore promotingadditional_propertiesto the root dictionary.additional_propertiesso that keys matchingexcludeor havingNonevalues (whenexclude_none=True) are excluded.packages/core/tests/core/test_clients.pycovering default exclusion ofNone, preservingNonewhenexclude_none=False, excluding all additional properties viaexclude={"additional_properties"}, and excluding individual property keys.What is the impact of these changes?
excludeandexclude_noneoptions across all client properties.Related Issue
Fixes #9940
AI Assistance
Contribution Checklist
cc Eduard van Valkenburg (@eavanvalkenburg)