Repository navigation
Show how to limit function and MCP tool output and retrieve the original - #6120
markstuart-oai wants to merge 2 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Approved after static review and an independent second review. Checked local preparation and MCP interception before conversion, custom-data extraction and span output; structured-content replacement and metadata removal; text-byte accounting, image preservation, per-run reference ownership/revocation, private retrieval, cancellation, and regression coverage. The documented exclusions for errors, small reports, images, and storage quotas match the implementation. No actionable findings. This example approval does not clear outstanding findings in the stacked base.
Hosted checks: {"SUCCESS": 16, "IN_PROGRESS": 3}. Pending checks retained for follow-up. Static review only; no candidate code or local tests were executed.
Hosted CI completion: 19 checks passed, 2 skipped; no pending or failed checks.
There was a problem hiding this comment.
Approved after static re-review and an independent second review. The local example tool now checks access before reading and after awaited bounding, and applies its output limit before an independent output editor can observe it. MCP report handling rechecks that storage is open before resolving tickets and after awaits, including the small-result path. Reviewed trusted owner/requester separation and the new unauthorized-read, revocation, independent-editor, cancellation, and short-report regressions. No actionable findings in this increment.
Hosted CI completed: 19 passed, 2 skipped. Static review only; no candidate code or local tests executed.
This example shows how to keep large tool results out of a conversation while letting the owner read the originals privately. It uses a local function tool and a tool discovered through MCP. Run it offline with
uv run python examples/mcp/bounded_tool_output/main.py.When a selected report exceeds 128 UTF-8 bytes of text, the tool returns a warning count and a random reference. The application can fetch the original in pages of up to 64 characters. Only the authenticated requester goes in the run context. The owner and originals stay in a private, per-run store. Closing the store revokes all references.
The local function checks access before reading, limits the text at the source and checks access again before returning. This keeps the limit in place even if the application replaces its output editor. The MCP wrapper checks access before the request and checks that the store is still open before resolving a local ticket and before returning a selected success.
Small reports, images, MCP errors and unselected results can still contain sensitive data. The example excludes native tools and provider-hosted MCP. No SDK defaults change.
Local verification