Skip to content

fix: infer MCP tool-call status from level/error when status field is absent - #34061

Merged
pelikhan merged 5 commits into
mainfrom
copilot/deep-report-fix-telemetry-capture
May 22, 2026
Merged

fix: infer MCP tool-call status from level/error when status field is absent#34061
pelikhan merged 5 commits into
mainfrom
copilot/deep-report-fix-telemetry-capture

Conversation

CopilotAI commented May 22, 2026

Copy link
Copy Markdown
Contributor

Post-OTel-collector migration, gateway.jsonl entries stopped emitting an explicit "status" string field. The parser blindly copied entry.Status (empty "") into MCPToolCall.Status, which downstream aggregators rendered as "unknown" — breaking error-rate, cost-per-tool, and retry analytics for all 165+ tool calls in the audit.

Changes

pkg/cli/gateway_logs_mcp.goextractToolCallsFromGatewayLog

  • When entry.Status == "", infer "error" if entry.Error != "" or entry.Level == "error", otherwise default to "success":
status:=entry.Statusifstatus=="" {
ifentry.Error!=""||entry.Level=="error" {
status="error"
} else {
status="success"
}
}

pkg/cli/gateway_logs_parsing.goprocessGatewayLogEntry

  • Extend error-tracking predicate to include entry.Level == "error" so TotalErrors/ErrorCount fields aren't under-counted for the new log format:
// beforeifentry.Status=="error"||entry.Error!="" {
// afterifentry.Status=="error"||entry.Error!=""||entry.Level=="error" {

Tests

  • TestExtractToolCallsStatusInference: 5 sub-cases — explicit status pass-through, level:"error" inference, error field inference, and level:"info" → success default.
  • TestProcessGatewayLogEntryLevelErrorCounting: verifies error counters increment when only level:"error" is present.

CopilotAIand others added 3 commits May 22, 2026 16:27
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
… absent
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…for status assert
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
CopilotAI changed the title [WIP] Fix MCP tool-call status=unknown in workflow audit telemetry capturefix: infer MCP tool-call status from level/error when status field is absentMay 22, 2026
CopilotAI requested a review from pelikhanMay 22, 2026 16:33
@pelikhan
pelikhan marked this pull request as ready for review May 22, 2026 17:30
CopilotAI review requested due to automatic review settings May 22, 2026 17:30

CopilotAI 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.

Pull request overview

This PR updates the MCP gateway log parser to handle post-OTel format drift where gateway.jsonl tool-call entries may omit the "status" field, ensuring tool-call status and error metrics are still computed correctly.

Changes:

  • Infer MCPToolCall.Status as "error" when level:"error" or error is present, otherwise default to "success" when status is absent.
  • Count log entries as errors when level:"error" is present (to avoid under-counting errors with missing status/error fields).
  • Add unit tests covering status inference and level-based error counting.
  • Update GitHub Actions lock/workflow files (includes a schedule change for the developer-docs consolidator workflow).
Show a summary per file
FileDescription
pkg/cli/gateway_logs_mcp.goInfer per-tool-call status when status is missing.
pkg/cli/gateway_logs_parsing.goTreat level:"error" entries as errors for metrics counting.
pkg/cli/gateway_logs_test.goAdd tests for status inference and level-based error counting.
.github/workflows/release.lock.ymlUpdate pinned docker/setup-buildx-action reference.
.github/workflows/developer-docs-consolidator.lock.ymlChange schedule to weekly and update lock content.
.github/aw/actions-lock.jsonAdd lock entry for docker/setup-buildx-action@v4.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 6/6 changed files
  • Comments generated: 2

Comment on lines +166 to 169
if entry.Status == "error" || entry.Error != "" || entry.Level == "error" {
metrics.TotalErrors++
if entry.ServerName != "" {
server := getOrCreateServer(metrics, entry.ServerName)
Comment on lines 69 to +71
schedule:
- cron: "19 13 * * *"
# Friendly format: daily (scattered)
- cron: "19 13 * * 6"
# Friendly format: weekly (scattered)
@pelikhan
pelikhan merged commit 6650c68 into mainMay 22, 2026
23 checks passed
@pelikhan
pelikhan deleted the copilot/deep-report-fix-telemetry-capture branch May 22, 2026 17:48
Sign up for freeto 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.

[deep-report] Fix MCP tool-call status=unknown telemetry capture in workflow audit

3 participants

@pelikhan