Files
codex/codex-rs/utils/output-truncation
Owen Lin be48ae396e Account for JSON overhead when truncating MCP tool results (#50470)
## Why

Truncating the preview alone can leave the serialized MCP tool result above its byte budget because JSON escaping and the result wrapper add bytes.

## What changed

Measure the complete serialized replacement and progressively reduce the preview budget until the result fits or the preview is empty.

## Testing

Strengthen the regression test with quotes, backslashes, and newlines. Assert that the serialized result fits within the 1,024-byte budget and that truncating it again returns the existing result unchanged.

GitOrigin-RevId: ebd97b1a6ca71343941a96e472cb313028ac680c
2026-10-03 00:13:58 +00:00
..