Repository navigation
Python: keep a streamed '{}' delta when combining function call arguments - #14513
PRABHU KIRAN VANDRANKI (VANDRANKI) wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Complete single-quoted objects followed by a placeholder now regress to invalid arguments.
Review effort: Balanced
Findings: 1
What changed in this PR
Updates streamed function-call argument merging so {} deltas are preserved when part of incomplete JSON.
Changes:
- Refines empty-placeholder handling.
- Adds streamed-delta and trailing-placeholder tests.
| File | Description |
|---|---|
python/semantic_kernel/contents/function_call_content.py |
Adds context-aware {} handling. |
python/tests/unit/contents/test_function_call_content.py |
Covers streamed empty-object deltas. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…g a trailing '{}' placeholder
|
The Copilot finding was right. Fixed in 0487868. |
|
The streaming fix and single-quote compatibility regression pass review. The remaining merge blocker is fresh required validation: the old Merge Gatekeeper, Spell Check, and .NET runs failed before producing checks. Those runs were created on October 1 and are beyond GitHub's rerun limit. Please update/rebase onto current main so fresh workflows can run. |
|
I updated this branch with current main (df1cb33). I merged main in instead of force pushing, so the new head 594679a is a normal merge commit. There were no conflicts and the PR diff is unchanged: 2 files, 56 lines added, 1 removed. On the pushed commit, tests/unit/contents and tests/unit/connectors/ai/test_function_choice_behavior.py give 474 passed. With function_call_content.py taken back to the main version, the 3 streamed The new workflow runs for 594679a show action_required, so a maintainer needs to approve them before they start. |

Motivation and Context
FunctionCallContent.combine_argumentstreated any"{}"string as an empty placeholder and dropped it. When a provider streams the arguments as raw token deltas and one delta is exactly{}, that delta is lost and the accumulated string is invalid JSON. For example{"query":"x","filters":+{}+}became{"query":"x","filters":}, andparse_arguments()then raisedFunctionCallInvalidArgumentsExceptionon a call the model produced correctly.Fixes #14512
Description
"{}"is no longer inEMPTY_VALUES. Only""andNoneare always treated as empty. The"{}"placeholder behavior the old code was written for is kept in the two places it makes sense:"{}", it is a finished empty object, so the second side replaces it (same as before)."{}"and the first side already parses as a complete JSON object, it is dropped (same as before).In every other case, including a
"{}"delta after a partial JSON string, the deltas are concatenated as plain text.Tests added in
tests/unit/contents/test_function_call_content.py: the three delta splits from the issue (they fail on current main and pass now) and the trailing-placeholder case. The existingtest_add_emptycases still pass.tests/unit/contentsandtests/unit/connectors/ai/test_function_choice_behavior.py: 429 passed.ruff formatandmypyare clean on the changed file.Contribution Checklist