Skip to content

Add MCP tool call error metrics#28976

Open
stevenlee-oai wants to merge 1 commit into
mainfrom
dev/stevenlee/mcp-error-metrics
Open

Add MCP tool call error metrics#28976
stevenlee-oai wants to merge 1 commit into
mainfrom
dev/stevenlee/mcp-error-metrics

Conversation

@stevenlee-oai

Copy link
Copy Markdown
Contributor

Codex Thread 019edc37-5345-7272-92c9-bf5494cf3819

Summary

  • count MCP CallToolResult.isError responses as failed calls instead of successful transport-level calls
  • add codex.mcp.call.error with bounded error_type and trusted plugin-service error_code dimensions
  • record the same error classification on MCP tool-call spans while keeping untrusted server error text out of metric labels

Scope

  • no changes to MCP routing, retries, tool behavior, configuration, or public APIs
  • request failures remain grouped as mcp_request; separating connection, timeout, protocol, and JSON-RPC failures requires preserving typed errors through the existing flattened error boundary

Testing

  • just test -p codex-core 'mcp_tool_call::tests::' (75 passed)
  • just fix -p codex-core
  • just fmt
  • just test -p codex-core (2,676 passed; 80 unrelated environment failures from missing test binaries, sandbox signals, and read-only paths)

@stevenlee-oai stevenlee-oai requested a review from a team as a code owner June 18, 2026 20:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d6030bc76

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +524 to +530
result
.structured_content
.as_ref()
.and_then(JsonValue::as_object)
.and_then(|structured_content| structured_content.get("error_code"))
.and_then(JsonValue::as_str)
.filter(|error_code| !error_code.is_empty())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Read hosted auth error codes from metadata

For hosted Codex Apps auth failures, this only looks at structuredContent.error_code, but the existing auth-failure shape stores the plugin-service code in _meta._codex_apps.connector_auth_failure.error_code (for example codex-rs/core/src/mcp_tool_call_tests.rs:1386-L1395, produced by codex-mcp/src/auth_elicitation.rs). Those common hosted tool-result errors will therefore be emitted as error_code=unknown, so the new codex.mcp.call.error dimension loses the specific auth failure code it is intended to surface.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant