fix(codemode): stop leaking undefined into tool arguments#37652
Merged
Conversation
github-actions Bot
pushed a commit
to ReStranger/opencode
that referenced
this pull request
Jul 19, 2026
* upstream/v2: mini: fix shell tool output display (anomalyco#37711) fix(core): detach disposed MCP registrations from root scope (anomalyco#37660) fix(core): preserve the first terminal failure (anomalyco#37705) fix(core): continue after malformed tool input (anomalyco#37701) fix(core): safely recover malformed tool input (anomalyco#37698) fix(simulation): render screenshot symbol glyphs (anomalyco#37691) fix(core): authorize relative external paths (anomalyco#37689) fix(tui): auto-approve permissions in auto mode feat(core): allow MCP Code Mode opt-out (anomalyco#37681) fix(codemode): stop leaking undefined into tool arguments (anomalyco#37652) fix(tui): style interrupted compaction neutrally (anomalyco#37655) fix(cli): harden managed service election (anomalyco#37645)
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.
Closes the outbound-handling gap from
interpreter-support.md(previously an unchecked item). Tool arguments now cross the boundary withJSON.stringifysemantics instead of passing rawundefinedthrough to tools.Behavior
For
tools.api.search({ q: undefined, limit: 0/0, items: [1, undefined, 2] })the tool now receives:undefinedvalues are dropped, like JSONundefinedarray elements and sparse holes becomenullnull(pre-existing behavior, unchanged)tools.t(undefined)still reaches schema decoding asundefined(matchesJSON.stringify(undefined)being undefined)The headline user-visible improvement: the ubiquitous
{ query: cond ? value : undefined }idiom now works against Effect schemas usingoptionalKey, which reject a present undefined value. Previously that call failed decoding; now the key is dropped before the schema runs — matching what any JSON-transported tool call would see.Program results deliberately keep the stricter normalization (
undefined->nulleverywhere), as doconsole.tablecolumns.Implementation
copyOut(value, undefinedAsNull?: boolean)becomescopyOut(value, mode: "raw" | "nullify" | "json")intool-runtime.ts. Tool invoke and built-in search args use"json"; execution results and console.table use"nullify"(the oldtrue);errors.ts/json.tskeep"raw"(the old default) where nativeJSON.stringifyalready applies these semantics itself.Testing
JSON.stringifybehaviorObject.hasOwn), sparse-hole densification, and theoptionalKeyacceptance change for both a user tool and the built-insearchinterpreter-support.mdupdated in the same PR; 911 tests pass frompackages/codemode