mirror of
https://github.com/openai/codex.git
synced 2026-11-28 07:32:19 +00:00
Let extensions process MCP tool results (#41202)
## What changed - Add `ToolLifecycleContributor::on_mcp_tool_result` with access to the executed MCP tool context, rewritten arguments, extension data stores, and mutable server result. - Run contributors before publishing MCP completion and before preparing the result for the model, so extensions can inspect or replace successful and error results. ## Testing - Cover unchanged, replaced, and error results for direct MCP calls, plus replaced and error results through Code Mode. - Verify completion waits for result processing and the processed result flows to both completion events and subsequent model input. GitOrigin-RevId: ece7acfe9c5eed4778cb78a29c3ffd06a74e1bcf
This commit is contained in:
1 parent
124e560b93
commit
5bf0ba3dd6
6 files changed
+278
-4
No files matched your search
@@ -6,6 +6,7 @@ use codex_config::McpServerConfig;
|
||||
use codex_mcp::McpServerSource;
|
||||
use codex_mcp::PreparedMcpCall;
|
||||
use codex_mcp::ResolvedMcpServer;
|
||||
use codex_protocol::mcp::CallToolResult;
|
||||
use codex_tools::ToolCallSource;
|
||||
use codex_tools::ToolName;
|
||||
use codex_tools::ToolPayload;
|
||||
@@ -138,6 +139,28 @@ pub struct ToolStartInput<'a> {
|
||||
pub source: ToolCallSource,
|
||||
}
|
||||
|
||||
/// Input supplied after an MCP server responds, before the host reports completion.
|
||||
pub struct McpToolResultInput<'a> {
|
||||
/// Store scoped to the host session runtime.
|
||||
pub session_store: &'a ExtensionData,
|
||||
/// Store scoped to this thread runtime.
|
||||
pub thread_store: &'a ExtensionData,
|
||||
/// Store scoped to this turn runtime.
|
||||
pub turn_store: &'a ExtensionData,
|
||||
/// Current turn submission id.
|
||||
pub turn_id: &'a str,
|
||||
/// Host tool call id, also used in the MCP completion notification.
|
||||
pub call_id: &'a str,
|
||||
/// Read-only metadata and provenance from the exact MCP call that executed.
|
||||
pub mcp_tool: &'a McpToolContext,
|
||||
/// Tool arguments after host-side rewriting, including file uploads.
|
||||
pub arguments: &'a serde_json::Value,
|
||||
/// Server response, including `_meta`. Changes feed the normal client and model output paths.
|
||||
///
|
||||
/// Arguments and results can contain sensitive plaintext and must not be logged.
|
||||
pub result: &'a mut CallToolResult,
|
||||
}
|
||||
|
||||
/// Input supplied when the host finishes executing one tool call.
|
||||
pub struct ToolFinishInput<'a> {
|
||||
/// Store scoped to the host session runtime.
|
||||
|
||||
Reference in new issue
Block a user