Repository navigation
Transform selected native MCP results before publication - #6133
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 comprehensive static review and independent native and Python reviews. Reviewed exact configured-peer selection, per-thread request ownership and one-shot replies, pinned Core callback ordering before completion/history/model publication, detached callback data, MCP replacement validation and the 1 MiB limit, preservation of peer errors, legacy-output-hook bypass, confirmed input rewrites, and failure/cancellation cleanup. The original result is replaced with a withheld placeholder before awaiting the callback, so a lost or rejected reply does not restore it. No actionable findings.
The documented limits are material and accurately stated: earlier Core traces may retain the original result; independently started child threads and non-configured tools are outside selection; a failed transform fails the SDK run, but Core may sample using the fixed placeholder. Reviewed regression coverage for media, structured content, error flags, history, native events, next model requests, invalid/oversized replacements, and cancellation.
Hosted CI is complete: 33 passed and 2 skipped; no failures. Static review only; no candidate code or local tests executed.
There was a problem hiding this comment.
Approved at 4e2da1c860929a5d60990ea80a6d169cc93b9ca7. Re-reviewed the two-file increment against the previously approved commit, with an independent second review. The shared diagnostics boundary now covers callback failures, replacement JSON serialization, and native validation, while retaining explicit diagnostic disclosure, cancellation semantics, and pending-result cleanup. Regression coverage includes rejected oversized and invalid replacements, lone surrogates in streamed runs, and detached redacted exceptions. No actionable findings.
Hosted CI is complete: 33 checks passed and 2 skipped; no failures. Static review only; no candidate code or local tests executed.
Summary
This pull request adds an opt-in callback for replacing a native MCP result before Codex publishes completion events, records history or sends the result to the model. The existing text hook runs after native completion events and skips peer errors.
Select a configured tool by its exact server and tool names. This example replaces the entire result with a status message and discards all media and structured content.
Pass
settingsasRunConfig(tool_execution=settings)when using the Codex provider. To keep media, edit the detached result and return it. CheckstructuredContentand_metafor other copies of sensitive values.prepare_tool_output. Unselected calls keep their existing behavior.A callback exception or a replacement that cannot be encoded as UTF-8 can carry tool data into error diagnostics. With tool-data redaction enabled (the default), Runner reports a fixed
UserErrorfor ordinary callback, encoding and validation errors. SettingOPENAI_AGENTS_DONT_LOG_TOOL_DATA=0preserves the original exception and can expose tool data. Cancellation and process-control exceptions still propagate. Application logs and arbitrary user tracebacks are outside this protection.Test plan
Checks
.agents/skills/code-change-verification/scripts/run.sh