Skip to content

Fix Go Logger safe-output accounting and failure diagnostics - #52661

Open
pelikhan with Copilot wants to merge 4 commits into
mainfrom
copilot/aw-failures-go-logger-enhancement
Open

Fix Go Logger safe-output accounting and failure diagnostics#52661
pelikhan with Copilot wants to merge 4 commits into
mainfrom
copilot/aw-failures-go-logger-enhancement

Conversation

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Go Logger runs misclassified safe-output discovery as repeated tool execution, while raw Claude tool_result annotations obscured the actionable timeout. The workflow also lacked an explicit single-terminal-action contract.

  • Tool accounting

    • Count only tool_call events and tools/call requests.
    • Exclude protocol discovery such as tools/list.
  • Failure reporting

    • Ignore annotated Claude tool_result payloads.
    • Preserve actionable runner and gateway errors.
  • Workflow guardrails

    • Require exactly one final outcome: create_pull_request, noop, or report_incomplete.
    • Prohibit safe-output probing and alternate-tool retries after rejection.
  • Regression coverage

    • Cover discovery-only gateway traffic, annotation filtering, and the Go Logger terminal-output contract.

Run: https://github.com/github/gh-aw/actions/runs/31795158705> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.47 AIC · ⌖ 7.2 AIC · ⊞ 8.5K ·

Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Go Logger Enhancement to call one safe-output tool per attempt Fix Go Logger safe-output accounting and failure diagnostics Aug 14, 2026
Copilot AI requested a review from pelikhan August 14, 2026 07:08
@pelikhan
pelikhan marked this pull request as ready for review August 14, 2026 10:57
Copilot AI balanced review requested due to automatic review settings August 14, 2026 10:57
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #52661 does not have the 'implementation' label and has 85 new lines of code in business logic directories (threshold: 100).

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #52661

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions github-actions 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.

Verdict

I did not find a blocking correctness, security, or performance regression in the changed lines.

The patch tightens MCP tool accounting, filters noisy tool-result annotations from error extraction, and adds regression tests for both behaviors plus the workflow contract text. I looked for changed-line breakage around undercounting real tool calls, masking actionable errors, and test gaps; the updated conditions and coverage are consistent with the stated intent.

No actionable review comments to add.

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 3.48 AIC · ⌖ 7.36 AIC · ⊞ 6.5K
Comment /review to run again

@github-actions github-actions 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.

The fixes are correct and well-tested. Gateway log accounting correctly excludes tools/list protocol discovery. Error line filtering prevents tool-result blobs from surfacing as errors. All test additions directly cover the fixed code paths.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 20.8 AIC · ⌖ 7 AIC · ⊞ 5.4K

Copilot AI 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

Fixes Go Logger safe-output accounting, failure diagnostics, and terminal-action guidance.

Changes:

  • Excludes protocol discovery from tool-call metrics.
  • Filters Claude tool_result error annotations.
  • Enforces one terminal safe-output action in Go Logger.
Show a summary per file
File Description
.github/workflows/go-logger.md Adds terminal-action guardrails.
.github/workflows/go-logger.lock.yml Updates generated workflow metadata.
pkg/cli/audit_mcp_tool_usage_test.go Tests discovery-only traffic.
pkg/cli/audit_report.go Filters tool-result annotations.
pkg/cli/audit_report_test.go Tests actionable error preservation.
pkg/cli/gateway_logs_mcp.go Restricts MCP usage extraction.
pkg/cli/gateway_logs_parsing.go Corrects tool-call accounting.
pkg/cli/gateway_logs_test.go Updates discovery accounting assertions.
pkg/workflow/prompts_test.go Verifies workflow guardrails.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 9/9 changed files
  • Comments generated: 1
  • Review effort level: Balanced

// Track tool calls
if entry.ToolName != "" || entry.Method != "" {
// Track only actual tool invocations, not protocol requests such as tools/list.
if entry.Event == "tool_call" || entry.Method == "tools/call" {
@github-actions github-actions Bot mentioned this pull request Aug 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Test Quality Sentinel Report 🧪

PR #52661 — "Fix Go Logger safe-output accounting and failure diagnostics"
Test Quality Score: 100/100EXCELLENT

Key Metrics

Metric Value Status
Design Contract Tests 5/5 (100%)
Edge Case / Error Coverage 5/5 (100%)
Implementation Tests 0/5 (0%) ✅ Pass (≤30%)
Test Inflation Ratio 1.83:1 ✅ Pass (≤2:1)
Hard Violations 0 ✅ None

Test Breakdown

5 Tests Analyzed (all design contract tests)
Test File Type Coverage Quality
"tool discovery is not tool usage" audit_mcp_tool_usage_test.go New case Boundary condition (discovery ≠ usage) HIGH
"ignores annotated tool results and surfaces the runner failure" audit_report_test.go New case Error filtering + JSON parsing HIGH
Modified assertions in TestGatewayLogsWithMethodField gateway_logs_test.go Modified Consistent metrics (tools/list not counted) MEDIUM-HIGH
TestGoLoggerDefinesSingleTerminalSafeOutputContract prompts_test.go New function Workflow safe-output guidance validation HIGH

Quality Strengths

All 5 tests enforce design invariants — not implementation details:

  • Test 1: Distinguishes protocol discovery from actual tool usage (boundary semantics)
  • Test 2: Validates error filtering behavior with realistic JSON structure
  • Test 3: Enforces consistent metrics across gateway tracking
  • Test 4: Ensures critical safe-output contract guidance is documented in workflow

100% edge case / error path coverage — every test includes boundary or error assertions

No code violations:

  • No forbidden mock libraries (gomock, testify/mock)
  • No missing build tags
  • All use real file I/O and JSON parsing (appropriate for integration-layer tests)

Healthy test-to-production ratio (1.83:1, within 2:1 threshold)

Clear failure context — all assertions use require or descriptive assert messages

Verdict

APPROVED ✅ — Test Quality Sentinel: 100/100. 0% implementation tests (threshold: 30%). No violations. All tests enforce strong design contracts around tool usage accounting, error filtering, and safe-output policy compliance.

🧪 Test quality analysis by Test Quality Sentinel · haiku45 · 19.3 AIC · ⌖ 3.85 AIC · ⊞ 7.6K ·
Comment /review to run again

@github-actions github-actions 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.

✅ Test Quality Sentinel: 100/100. 0% implementation tests (threshold: 30%). No violations. All tests enforce strong design contracts around tool usage accounting, error filtering, and safe-output policy compliance.

@github-actions github-actions 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.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd — the fixes are well-targeted; leaving a few improvement suggestions.

📋 Key Themes & Highlights

Key Themes

  • Suppression over-breadth (audit_report.go): isAgentToolResultAnnotation returns true if any content item is a tool_result, meaning mixed-content messages with a real error text are still silently dropped.
  • Brittle contract test (prompts_test.go): Asserting exact prose strings couples the test to formatting rather than semantic intent; any rewording breaks it.
  • Server-counter asymmetry undocumented (audit_mcp_tool_usage_test.go): Discovery-only traffic filters tool calls but still registers a server entry — the test asserts this but doesn't explain why.

Positive Highlights

  • ✅ Root-cause fix in both gateway_logs_mcp.go and gateway_logs_parsing.go is consistent and correct.
  • ✅ Regression test for annotation filtering is well-structured with a real-world timeout message.
  • ✅ Workflow guardrails are clear, actionable, and directly address the reported failure mode.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 42.4 AIC · ⌖ 8.48 AIC · ⊞ 7K
Comment /matt to run again

Comment thread pkg/cli/audit_report.go
if err := json.Unmarshal([]byte(strings.TrimSpace(payload)), &event); err != nil || event.Type != "user" {
return false
}
for _, content := range event.Message.Content {

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.

[/diagnosing-bugs] If a ##[error] line contains mixed content — a tool_result alongside another content type (e.g. "type":"text") — the entire line is silently suppressed, hiding a real error.

💡 Suggested guard

Return true only when all content items are tool_result, not when any one of them is:

hasToolResult := false
hasOtherContent := false
for _, c := range event.Message.Content {
    if c.Type == "tool_result" {
        hasToolResult = true
    } else {
        hasOtherContent = true
    }
}
return hasToolResult && !hasOtherContent

This keeps suppression for pure annotation messages while surfacing mixed content that includes real error text.

@copilot please address this.

logContent: `{"timestamp":"2024-01-12T10:00:00Z","level":"info","type":"request","event":"rpc_call","server_name":"safeoutputs","method":"tools/list","duration":50.0,"status":"success"}
{"timestamp":"2024-01-12T10:00:01Z","level":"info","type":"request","event":"request","server_name":"safeoutputs","method":"tools/list","duration":50.0,"status":"success"}
`,
wantServers: 1,

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.

[/tdd] The new test case sets wantServers: 1 for a log that contains only tools/list events, but after the fix, discovery-only traffic should arguably not register a server at all — or the test should document why a server entry is still expected.

💡 Detail

If wantServers is 1 because the ServerName field in a tools/list entry still creates a server bucket, the test is correct but the assertion silently documents that the server counter is not subject to the same filtering as tool calls. Consider adding a comment explaining this intentional asymmetry, or reconsider whether discovery-only traffic should increment the server counter.

@copilot please address this.

Comment thread pkg/workflow/prompts_test.go Outdated
}

workflow := string(content)
for _, guidance := range []string{

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.

[/tdd] This test is brittle: it asserts exact prose strings from the workflow file. Any whitespace edit, rewording, or reflow of those sentences will cause the test to fail without a real contract violation.

💡 Suggested approach

Extract the semantic intent into constants or a helper and check for the key tokens rather than the full sentence:

checks := []struct{ name, keyword string }{
    {"single terminal outcome", "exactly one terminal outcome"},
    {"no probing", "Do not probe safe outputs"},
    {"no retry after rejection", "stop immediately and surface its exact rejection message"},
}
for _, c := range checks {
    require.Contains(t, workflow, c.keyword, "go-logger workflow missing contract: %s", c.name)
}

This keeps the intent assertion stable across minor prose edits.

@copilot please address this.

@github-actions github-actions 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.

Generated by ✂️ Ponytail Reviewer for #52661 · auto · 32.2 AIC · ⌖ 4.34 AIC · ⊞ 6.8K
Comment /ponytail to run again

Comment thread pkg/cli/audit_report.go
}
}
return false
}

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.

L857-880: yagni: full JSON struct decode (nested Type/Message/Content) just to check for a tool_result content type. strings.Contains(payload, "tool_result") gets the same filtering result in ~2 lines, no struct needed.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot
Quick triage for maintainer-ready follow-up:

Unresolved review threads (newest first):

Failed checks:

Please refresh the branch if needed, address the unresolved review feedback, rerun validation, and use the pr-finisher skill before handing back.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.47 AIC · ⌖ 7.2 AIC · ⊞ 8.5K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

@copilot
Quick triage for maintainer-ready follow-up:
...

Addressed the actionable feedback in 8ca697f: corrected the legacy RPC expectation, preserved mixed-content error annotations, documented discovery-only server accounting, and relaxed the workflow contract test.

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage\n\n- Category: bug\n- Risk: medium\n- Priority: medium\n- Score: 60/100 (impact 35 + urgency 15 + quality 10)\n- Recommended action: fast_track\n

Generated by 🔧 PR Triage Agent · auto · 62.8 AIC · ⌖ 2.76 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: bug
  • Risk: medium
  • Priority: medium (score: 54/100)
  • Score breakdown: impact 25/50, urgency 15/30, quality 14/20
  • Recommended action: batch_review
  • Batch: bugfix-medium-cluster

Automated triage by PR Triage Agent.

Generated by 🔧 PR Triage Agent · auto · 64.3 AIC · ⌖ 2.94 AIC · ⊞ 7.8K ·

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw-failures] [P1] Go Logger Enhancement fires 6 conflicting safe-output tools per retry attempt

4 participants