Repository navigation
Conversation
imorland
requested review from
CodeWithKyrian,
Nyholm,
chr-hertel and
soyuka
as code owners
November 6, 2026 16:00
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the changes distinguishing omitted structured content from explicit JSON null.
No open issues 🎉
What changed in this PR
Addresses #673 by distinguishing omitted structured content from explicit JSON null in the PHP SDK’s tool results, while preserving legacy automatic wrapping behavior.
Changes:
- Adds an absence sentinel and
hasStructuredContent()to preserve null through construction, serialization, and decoding. - Updates modern server wrapping and output-schema validation to handle explicit null.
- Adds regression coverage and documents the behavior and compatibility changes.
| File | Description |
|---|---|
tests/Unit/Server/Handler/Request/CallToolHandlerTest.php |
Distinguishes legacy warnings for explicit null and omitted content. |
tests/Unit/Schema/Result/CallToolResultTest.php |
Covers omission, explicit null, helper factories, and round trips. |
tests/Integration/StructuredNullTest.php |
Covers null wrapping, validation, and client decoding across protocol eras. |
tests/Integration/Fixture/structured_null.php |
Provides tools returning absent, explicit, serialized, and invalid null results. |
src/Server/Handler/Request/CallToolHandler.php |
Preserves modern null results and validates present structured content. |
src/Schema/Result/CallToolResult.php |
Tracks structured-content presence separately from its value. |
src/Schema/Enum/UndefinedValue.php |
Introduces the sentinel for omitted structured content. |
docs/servers/tools.md |
Explains null handling and migration from null-as-omission. |
CHANGELOG.md |
Records server behavior and the schema compatibility break. |
Review effort: Balanced
This branch has not been 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.
Preserve explicit JSON null in structured tool results while keeping omitted content absent through construction, helper factories and decoding. Apply the distinction to modern server wrapping and output validation, with legacy automatic wrapping unchanged.
Fixes #673 (Explicit structuredContent: null is omitted from tool results).