fix(codemode): truncate structured results structurally and keep the call log out of model context (#2224)
* fix(codemode): truncate structured results structurally and keep the call log out of model context truncateResult shrinks an oversized value in place, largest values first, so the model always receives valid JSON of the original shape. The MCP servers shape results on the host with it instead of slicing pretty-printed JSON. The Code Mode tool gains a toModelOutput that drops the durable calls log from what the model sees; the persisted output keeps it for UIs. Compaction summaries serialize structured tool outputs as JSON. Closes #2009, #2143, #2182, #2138. * fix(codemode): make structural truncation budget-honest and keep logs/calls bounded for the model Review findings: the array prefix search assumed a monotone predicate and could drop every element when the whole array fit; the object fallback marker was unbounded, so a long list of small records overshot its slot and fell back to the string slice this PR removes. Shrinking now guarantees its budget by construction: every child is owed a floor, containers only drop children when the floors cannot fit, and markers are clipped to the room left. A real key named like the marker is no longer shadowed. The MCP servers apply the response budget to the emitted text (pretty only while it fits). toModelOutput bounds logs, renders BigInt, and never throws on a cycle. browser_execute drops calls from its model projection too. * fix(codemode): linear object shrinking, bounded omitted-key note, bounded browser logs shrinkObject tracks costs incrementally instead of rescanning every entry per drop, and the omitted-key note is allocated and shrunk like any other value so it can never overshoot its slot. browser_execute bounds logs in its model projection like the codemode tool does.
M
Matt committed
dcca0896cc829e4a602a1feb47466ac79d1ca096
Parent: dd8bf90
Committed by GitHub <noreply@github.com>
on 9/9/2026, 2:09:38 PM