mirror of
https://github.com/openai/codex.git
synced 2026-09-06 15:29:32 +00:00
Preserve MCP metadata
This commit is contained in:
@@ -224,6 +224,7 @@ impl EventProcessorWithJsonOutput {
|
||||
result: result.map(|result| McpToolCallItemResult {
|
||||
content: result.content,
|
||||
structured_content: result.structured_content,
|
||||
meta: result.meta,
|
||||
}),
|
||||
error: error.map(|error| McpToolCallItemError {
|
||||
message: error.message,
|
||||
|
||||
@@ -267,6 +267,9 @@ pub struct McpToolCallItemResult {
|
||||
// easy to export.
|
||||
pub content: Vec<JsonValue>,
|
||||
pub structured_content: Option<JsonValue>,
|
||||
#[serde(rename = "_meta", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional, rename = "_meta")]
|
||||
pub meta: Option<JsonValue>,
|
||||
}
|
||||
|
||||
/// Error details reported by a failed MCP tool invocation.
|
||||
|
||||
@@ -541,6 +541,7 @@ fn mcp_tool_call_begin_and_end_emit_item_events() {
|
||||
result: Some(McpToolCallItemResult {
|
||||
content: Vec::new(),
|
||||
structured_content: None,
|
||||
meta: None,
|
||||
}),
|
||||
error: None,
|
||||
status: McpToolCallStatus::Completed,
|
||||
@@ -601,7 +602,7 @@ fn mcp_tool_call_failure_sets_failed_status() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mcp_tool_call_defaults_arguments_and_preserves_structured_content() {
|
||||
fn mcp_tool_call_defaults_arguments_and_preserves_structured_content_and_meta() {
|
||||
let mut processor = EventProcessorWithJsonOutput::new(/*last_message_path*/ None);
|
||||
|
||||
let started =
|
||||
@@ -636,7 +637,11 @@ fn mcp_tool_call_defaults_arguments_and_preserves_structured_content() {
|
||||
"text": "done",
|
||||
})],
|
||||
structured_content: Some(json!({ "status": "ok" })),
|
||||
meta: None,
|
||||
meta: Some(json!({
|
||||
"raw_messages": [
|
||||
{ "ref_id": "abc123" }
|
||||
],
|
||||
})),
|
||||
})),
|
||||
error: None,
|
||||
duration_ms: Some(10),
|
||||
@@ -682,6 +687,11 @@ fn mcp_tool_call_defaults_arguments_and_preserves_structured_content() {
|
||||
"text": "done",
|
||||
})],
|
||||
structured_content: Some(json!({ "status": "ok" })),
|
||||
meta: Some(json!({
|
||||
"raw_messages": [
|
||||
{ "ref_id": "abc123" }
|
||||
],
|
||||
})),
|
||||
}),
|
||||
error: None,
|
||||
status: McpToolCallStatus::Completed,
|
||||
|
||||
Reference in New Issue
Block a user