mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Include connector IDs in MCP tool call analytics (#32867)
## What changed - Add the optional `connector_id` to `codex_mcp_tool_call_event` parameters. - Populate it from the MCP tool call's `app_context` when available. ## Testing - Extend the completed tool item analytics test to verify the connector ID is serialized. GitOrigin-RevId: ea62202318dd492fa0ffd4ff1d48a66d1cc37e96
This commit is contained in:
1 parent
6e113acf5f
commit
bbfa08fe3b
3 files changed
+18
-1
No files matched your search
@@ -111,6 +111,7 @@ use codex_app_server_protocol::ItemCompletedNotification;
|
|||||||
use codex_app_server_protocol::ItemGuardianApprovalReviewCompletedNotification;
|
use codex_app_server_protocol::ItemGuardianApprovalReviewCompletedNotification;
|
||||||
use codex_app_server_protocol::ItemStartedNotification;
|
use codex_app_server_protocol::ItemStartedNotification;
|
||||||
use codex_app_server_protocol::JSONRPCErrorError;
|
use codex_app_server_protocol::JSONRPCErrorError;
|
||||||
|
use codex_app_server_protocol::McpToolCallAppContext;
|
||||||
use codex_app_server_protocol::McpToolCallStatus;
|
use codex_app_server_protocol::McpToolCallStatus;
|
||||||
use codex_app_server_protocol::NonSteerableTurnKind;
|
use codex_app_server_protocol::NonSteerableTurnKind;
|
||||||
use codex_app_server_protocol::PatchApplyStatus;
|
use codex_app_server_protocol::PatchApplyStatus;
|
||||||
@@ -4353,7 +4354,14 @@ async fn turn_event_counts_completed_tool_items() {
|
|||||||
tool: "search".to_string(),
|
tool: "search".to_string(),
|
||||||
status,
|
status,
|
||||||
arguments: json!({}),
|
arguments: json!({}),
|
||||||
app_context: None,
|
app_context: Some(McpToolCallAppContext {
|
||||||
|
connector_id: "connector-test".to_string(),
|
||||||
|
link_id: None,
|
||||||
|
resource_uri: None,
|
||||||
|
app_name: None,
|
||||||
|
template_id: None,
|
||||||
|
action_name: None,
|
||||||
|
}),
|
||||||
mcp_app_resource_uri: None,
|
mcp_app_resource_uri: None,
|
||||||
plugin_id: Some("sample@test".to_string()),
|
plugin_id: Some("sample@test".to_string()),
|
||||||
result: None,
|
result: None,
|
||||||
@@ -4445,6 +4453,10 @@ async fn turn_event_counts_completed_tool_items() {
|
|||||||
.expect("MCP tool call event should be emitted");
|
.expect("MCP tool call event should be emitted");
|
||||||
let payload = serde_json::to_value(mcp_tool_call_event).expect("serialize MCP tool call event");
|
let payload = serde_json::to_value(mcp_tool_call_event).expect("serialize MCP tool call event");
|
||||||
assert_eq!(payload["event_params"]["plugin_id"], json!("sample@test"));
|
assert_eq!(payload["event_params"]["plugin_id"], json!("sample@test"));
|
||||||
|
assert_eq!(
|
||||||
|
payload["event_params"]["connector_id"],
|
||||||
|
json!("connector-test")
|
||||||
|
);
|
||||||
|
|
||||||
reducer
|
reducer
|
||||||
.ingest(
|
.ingest(
|
||||||
|
|||||||
@@ -674,6 +674,7 @@ pub(crate) struct CodexMcpToolCallEventParams {
|
|||||||
pub(crate) mcp_tool_name: String,
|
pub(crate) mcp_tool_name: String,
|
||||||
pub(crate) mcp_error_present: bool,
|
pub(crate) mcp_error_present: bool,
|
||||||
pub(crate) plugin_id: Option<String>,
|
pub(crate) plugin_id: Option<String>,
|
||||||
|
pub(crate) connector_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
|||||||
@@ -1884,6 +1884,7 @@ fn tool_item_event(input: ToolItemEventInput<'_>) -> Option<TrackEventRequest> {
|
|||||||
error,
|
error,
|
||||||
duration_ms,
|
duration_ms,
|
||||||
plugin_id,
|
plugin_id,
|
||||||
|
app_context,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
let (terminal_status, failure_kind) = mcp_tool_call_outcome(status)?;
|
let (terminal_status, failure_kind) = mcp_tool_call_outcome(status)?;
|
||||||
@@ -1915,6 +1916,9 @@ fn tool_item_event(input: ToolItemEventInput<'_>) -> Option<TrackEventRequest> {
|
|||||||
mcp_tool_name: tool.clone(),
|
mcp_tool_name: tool.clone(),
|
||||||
mcp_error_present: error.is_some(),
|
mcp_error_present: error.is_some(),
|
||||||
plugin_id: plugin_id.clone(),
|
plugin_id: plugin_id.clone(),
|
||||||
|
connector_id: app_context
|
||||||
|
.as_ref()
|
||||||
|
.map(|app_context| app_context.connector_id.clone()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
|||||||
Reference in new issue
Block a user