Skip to content

Truncate oversized MCP results in paginated thread history - #50458

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/09dce73c70bfd357c9b9630f456e9e5c1d8492cf
Oct 2, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/09dce73c70bfd357c9b9630f456e9e5c1d8492cf

Conversation

@copyberry

@copyberry copyberry Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Truncate oversized MCP results in paginated thread history

Why

Paginated thread history can persist large MCP results in completed tool-call items. Bound these stored results to avoid retaining multi-megabyte payloads.

What changed

Apply a 64 KiB preview budget when persisting oversized MCP results in paginated history. Replace the result with a truncated text preview of its serialized JSON, preserving is_error and clearing structuredContent and _meta. Leave small results unchanged.

Share the truncation helper with the existing MCP tool-call event path.

Testing

Add helper tests for unchanged small results and oversized results with structured content and metadata. Add a thread-history test verifying that persisted MCP results contain a bounded preview with the beginning, end, and truncation marker while preserving tool arguments.

## Why

Paginated thread history can persist large MCP results in completed tool-call items. Bound these stored results to avoid retaining multi-megabyte payloads.

## What changed

Apply a 64 KiB preview budget when persisting oversized MCP results in paginated history. Replace the result with a truncated text preview of its serialized JSON, preserving `is_error` and clearing `structuredContent` and `_meta`. Leave small results unchanged.

Share the truncation helper with the existing MCP tool-call event path.

## Testing

Add helper tests for unchanged small results and oversized results with structured content and metadata. Add a thread-history test verifying that persisted MCP results contain a bounded preview with the beginning, end, and truncation marker while preserving tool arguments.

GitOrigin-RevId: 09dce73c70bfd357c9b9630f456e9e5c1d8492cf
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/09dce73c70bfd357c9b9630f456e9e5c1d8492cf branch from cf2ff39 to 820f85c Compare October 2, 2026 23:15
@copyberry
copyberry Bot merged commit 820f85c into main Oct 2, 2026
1 check passed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/09dce73c70bfd357c9b9630f456e9e5c1d8492cf branch October 2, 2026 23:15
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant