fix: emit [] not null for empty tool output collections#96
Open
bobby-smedley wants to merge 1 commit into
Open
fix: emit [] not null for empty tool output collections#96bobby-smedley wants to merge 1 commit into
bobby-smedley wants to merge 1 commit into
Conversation
MieszkoWasniowski
approved these changes
Jul 14, 2026
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.
🎯 What does this PR do?
Fixes an intermittent error where a tool could fail with:
validating tool output: ... /properties/results: has type "null", want "array"
What was wrong: chip generates each tool's schema from its Go types. An earlier fix cleaned those schemas up so every list/map is described as a plain
"array"/"object"instead of "a list or nothing" — that stopped some clients (e.g. Cowork) from mis-sending list arguments. The catch: the same cleanup also applied to the output schemas, which now disallow "nothing" (null). But in Go, a list that was never filled in becomesnullwhen converted to JSON. So whenever a tool returned no results (an empty search, or an early error like "asset not found"), it emittednulland failed its own output check. It looked random because it only happened on the empty path — any response with results worked fine.The fix: rather than loosen the schema again (which would undo the input fix), we make the data match the schema. Right before a tool's response leaves the server, any unset list becomes an empty list
[]and any unset map becomes{}. This is done once, in one shared place, so it covers every tool — current and future — with no per-tool changes.Safety: the schema and the input-side fix are untouched — we only change the outgoing data. Empty collections still satisfy
omitempty, so optional fields are still omitted, and the schema clients see is unchanged. Adds unit and end-to-end tests, including one that confirms the bug returns if the fix is removed.✅ Checklist