mirror of
https://github.com/openai/codex.git
synced 2026-12-06 01:10:58 +00:00
Deduplicate MCP text fallbacks in Code Mode output (#63540)
## Why MCP tools can return structured data alongside a JSON text fallback for clients that need it. Printing the whole result in Code Mode can show the same data twice. ## What changed Enable `features.code_mode_mcp_result_dedup` to let `text()` omit `content` when it prints an original, successful MCP result whose only content block is a plain text fallback that parses to the same JSON as `structuredContent`. The JavaScript result retains both fields. Carry the result format through gRPC so the host can distinguish MCP results from ordinary JSON. The feature is off by default. ## Testing Add coverage for both feature flag settings, for printing original MCP results and copies through gRPC, and for comparing equivalent JSON. GitOrigin-RevId: a8b0b42f5375d9744c235a0e663090dd5982e37e
This commit is contained in:
@@ -7,6 +7,7 @@ use std::sync::Arc;
|
||||
use std::sync::atomic::AtomicU64;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
use codex_code_mode_protocol::CodeModeToolResult;
|
||||
pub(crate) use codex_code_mode_protocol::FunctionCallOutputContentItem as OutputItem;
|
||||
use opentelemetry::context::FutureExt;
|
||||
use serde_json::Value as JsonValue;
|
||||
@@ -256,7 +257,7 @@ impl<D: SessionRuntimeDelegate> CellHost for RuntimeCellHost<D> {
|
||||
&self,
|
||||
invocation: CellToolCall,
|
||||
cancellation_token: CancellationToken,
|
||||
) -> Result<JsonValue, String> {
|
||||
) -> Result<CodeModeToolResult, String> {
|
||||
self.delegate
|
||||
.invoke_tool(
|
||||
NestedToolCall {
|
||||
|
||||
@@ -24,8 +24,8 @@ impl SessionRuntimeDelegate for RecordingDelegate {
|
||||
&self,
|
||||
_invocation: NestedToolCall,
|
||||
_cancellation_token: CancellationToken,
|
||||
) -> Result<JsonValue, String> {
|
||||
Ok(JsonValue::Null)
|
||||
) -> Result<CodeModeToolResult, String> {
|
||||
Ok(CodeModeToolResult::from(JsonValue::Null))
|
||||
}
|
||||
|
||||
async fn notify(
|
||||
@@ -46,8 +46,8 @@ impl SessionRuntimeDelegate for PanickingClosedDelegate {
|
||||
&self,
|
||||
_invocation: NestedToolCall,
|
||||
_cancellation_token: CancellationToken,
|
||||
) -> Result<JsonValue, String> {
|
||||
Ok(JsonValue::Null)
|
||||
) -> Result<CodeModeToolResult, String> {
|
||||
Ok(CodeModeToolResult::from(JsonValue::Null))
|
||||
}
|
||||
|
||||
async fn notify(
|
||||
|
||||
@@ -3,6 +3,7 @@ use std::future::Future;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use codex_code_mode_protocol::CodeModeToolResult;
|
||||
use serde_json::Value as JsonValue;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
@@ -126,7 +127,7 @@ pub(crate) trait SessionRuntimeDelegate: Send + Sync + 'static {
|
||||
&self,
|
||||
invocation: NestedToolCall,
|
||||
cancellation_token: CancellationToken,
|
||||
) -> impl Future<Output = Result<JsonValue, String>> + Send;
|
||||
) -> impl Future<Output = Result<CodeModeToolResult, String>> + Send;
|
||||
|
||||
fn notify(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user