Skip to content

Fix false positive AI credits rate limit and agentic engine timeout detections - #49750

Merged
pelikhan merged 4 commits into
mainfrom
copilot/aw-fix-daily-experiment-report
Aug 2, 2026
Merged

Fix false positive AI credits rate limit and agentic engine timeout detections#49750
pelikhan merged 4 commits into
mainfrom
copilot/aw-fix-daily-experiment-report

Conversation

Copilot AI commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Workflow failure reports were simultaneously claiming "AI credits rate limit (HTTP 429)" and "Agent Timed Out" for runs where neither actually occurred — the real failure was authentication_failed with a post-result watchdog SIGTERM.

False positive 1: AI credits rate limit (parse_mcp_gateway_log.cjs)

hasAICreditsRateLimitError() was being called on rpc-messages.jsonl and gateway.jsonl, which contain raw MCP tool call response payloads (branch listings, commit messages). Repository data like branch names schema-coverage-rate-limit-* and commit messages mentioning "AI credits throughput rate-limit errors" matched the patterns.

Fix: Remove hasAICreditsRateLimitError calls on MCP RPC message files. Real Copilot API 429s only appear in gateway.md, gateway.log, and stderr.log.

False positive 2: Agentic engine timeout (detect_agent_errors.cjs)

AGENTIC_ENGINE_TIMEOUT_PATTERN matched any signal=SIGTERM, including the copilot-harness post-result watchdog — which fires when the agent process sits idle ~20s after completing work, not because the step timed out. The distinguishing marker watchdogFired=true exists on the process closed log line but was never checked.

Fix: Add isAgenticEngineTimeout() with two new patterns:

// Matches: process closed ... signal=SIGTERM ... watchdogFired=true
const WATCHDOG_SIGTERM_PATTERN = /process closed[^\n]*signal=SIG(?:TERM|KILL|INT)[^\n]*watchdogFired=true/;

// Matches: process closed ... signal=SIGTERM ... (no watchdogFired=true)
const STEP_TIMEOUT_SIGTERM_PATTERN = /process closed[^\n]*signal=SIG(?:TERM|KILL|INT)(?![^\n]*watchdogFired=true)/;

If all process closed SIGTERM lines have watchdogFired=true, the function returns false (not a timeout). detectErrors() now calls isAgenticEngineTimeout() instead of the raw pattern.

Regression tests added for both fixes covering watchdog-only, step-timeout, mixed, and the rpc-messages.jsonl branch-name false positive scenario.


Run: https://github.com/github/gh-aw/actions/runs/30750494960

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12 AIC · ⌖ 7.39 AIC · ⊞ 8.3K ·
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix AI credits rate limit issue in daily experiment report Fix false positive AI credits rate limit and agentic engine timeout detections Aug 2, 2026
Copilot AI requested a review from pelikhan August 2, 2026 10:54
@pelikhan
pelikhan marked this pull request as ready for review August 2, 2026 11:17
Copilot AI review requested due to automatic review settings August 2, 2026 11:17

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 false-positive AI credit rate-limit and agent timeout reporting from MCP payloads and watchdog termination logs.

Changes:

  • Excludes raw MCP JSONL payloads from rate-limit detection.
  • Distinguishes watchdog termination from genuine engine timeouts.
  • Adds regression coverage for both scenarios.
Show a summary per file
File Description
actions/setup/js/parse_mcp_gateway_log.cjs Restricts rate-limit scanning sources.
actions/setup/js/parse_mcp_gateway_log.test.cjs Tests MCP payload false positives.
actions/setup/js/detect_agent_errors.cjs Adds watchdog-aware timeout detection.
actions/setup/js/detect_agent_errors.test.cjs Tests watchdog, timeout, and mixed cases.

Review details

Tip

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

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

Comment on lines +845 to +849
// Do NOT scan gateway.jsonl / rpc-messages.jsonl for AI credits rate limit errors.
// These files contain full MCP tool call request/response payloads including arbitrary
// repository data (branch names, commit messages, file contents) that can false-positively
// match the rate-limit patterns. Real AI credits rate limit errors from the inference API
// appear in gateway.log / stderr.log / gateway.md, not in MCP RPC message logs.
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

PR Triage

  • Category:
  • Risk:
  • Priority: (score: 53/100)
    • Impact: 27/50, Urgency: 10/30, Quality: 16/20
  • Recommended action:
  • Batch:

Automated triage — see full report issue for details.

Structured data:

{
  "action": "batch_review",
  "category": "bug",
  "pr_number": 49750,
  "risk": "medium"
}

Generated by 🔧 PR Triage Agent · auto · 73.4 AIC · ⌖ 3.47 AIC · ⊞ 8K ·

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

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

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

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed during code quality review.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

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

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

Fix is correct and well-tested. isAgenticEngineTimeout correctly distinguishes post-result watchdog SIGTERMs from genuine step-timeout kills. Removing hasAICreditsRateLimitError scans from JSONL files eliminates false positives from arbitrary repository content. Test coverage is comprehensive. No blocking issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 29 AIC · ⌖ 7.38 AIC · ⊞ 5.4K

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 90/100 — Excellent

Analyzed 50 tests (sampled from 207 total across 2 JS files): ~48 design, ~2 implementation, 0 violations.
⚠️ Sampling note: 207 test cases found; analyzed the first 50 per the 50-function budget. Prioritized newly added pattern groups and edge cases.

📊 Metrics (50 sampled tests)
Metric Value
Analyzed 50 sampled (Go: 0, JS: 50)
✅ Design 48 (96%)
⚠️ Implementation 2 (4%)
Edge/error coverage 50 (100%)
Duplicate clusters 0
Inflation YES (both files exceed 2:1; advisory only — see note)
🚨 Violations 0
Test Group File Classification Issues
AGENTIC_ENGINE_TIMEOUT_PATTERN detect_agent_errors.test.cjs design_test / high_value None
isAgenticEngineTimeout (watchdogFired logic) detect_agent_errors.test.cjs design_test / high_value None
CAPI_QUOTA_EXCEEDED_PATTERN / isCAPIQuotaExceededError detect_agent_errors.test.cjs design_test / high_value None
INVOCATION_CAP_EXCEEDED_PATTERN detect_agent_errors.test.cjs design_test / high_value None
MISSING_MODEL_PRICING_PATTERN detect_agent_errors.test.cjs design_test / high_value None
detectErrors integration group detect_agent_errors.test.cjs design_test / high_value None
buildOutputLines output format detect_agent_errors.test.cjs implementation_test / low_value Verifies internal output string format
generatePlainTextGatewaySummary parse_mcp_gateway_log.test.cjs design_test / high_value None
generateGatewayLogSummary parse_mcp_gateway_log.test.cjs design_test / high_value None
main() null-byte stripping parse_mcp_gateway_log.test.cjs design_test / high_value None
i️ Inflation Note (advisory only)

Both test files exceed the 2:1 ratio of test lines added vs. production lines added:

  • detect_agent_errors.test.cjs: +123 test lines vs +44 prod lines → 2.8:1
  • parse_mcp_gateway_log.test.cjs: +108 test lines vs +8 prod lines → 13.5:1

This is expected and appropriate for a false-positive fix PR. The production change is a targeted regex refinement (watchdogFired=true exclusion, session.idle scoping, AI-credits rate-limit pattern), while the tests exhaustively cover all affected branches, negative cases, and production log shapes. The inflation reflects thorough regression coverage, not quality problems. The 10-point bonus is withheld per the scoring formula, but this is not a quality concern.

Verdict

passed. 4% implementation tests (threshold: 30%). No violations.

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 · 58.2 AIC · ⌖ 8.37 AIC · ⊞ 8.4K ·
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: 90/100. 4% implementation tests (threshold: 30%). No violations.

@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 — requesting changes on two issues.

📋 Key Themes & Highlights

Key Themes

  • Incomplete false-positive fix: hasUnknownModelAICreditsError still scans gateway.jsonl and rpc-messages.jsonl, the same false-positive vector just fixed for hasAICreditsRateLimitError.
  • Ambiguous SIGTERM fallback: isAgenticEngineTimeout returns true for any SIGTERM not on a process closed line, which may be too broad.
  • Missing detectErrors integration test for the mixed watchdog + step-timeout case.

Positive Highlights

  • ✅ Excellent root-cause analysis and clear PR description
  • ✅ Good regression tests for both fixes, including the exact failing run scenario
  • ✅ Clean separation of isAgenticEngineTimeout with well-documented JSDoc
  • ✅ Exporting the new patterns and function enables direct unit testing

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 49.4 AIC · ⌖ 8.24 AIC · ⊞ 7.1K
Comment /matt to run again

// repository data (branch names, commit messages, file contents) that can false-positively
// match the rate-limit patterns. Real AI credits rate limit errors from the inference API
// appear in gateway.log / stderr.log / gateway.md, not in MCP RPC message logs.
unknownModelAICredits ||= hasUnknownModelAICreditsError([jsonlContent]);

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.

// repository data (branch names, commit messages, file contents) that can false-positively
// match the rate-limit patterns. Real AI credits rate limit errors from the inference API
// appear in gateway.log / stderr.log / gateway.md, not in MCP RPC message logs.
unknownModelAICredits ||= hasUnknownModelAICreditsError([jsonlContent]);

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] hasUnknownModelAICreditsError still scans gateway.jsonl and rpc-messages.jsonl — the same false-positive vector that motivated removing the hasAICreditsRateLimitError calls. Branch names or commit messages containing unknown_model_ai_credits could trigger this.

💡 Suggested fix

Remove lines 850 and 870 (the JSONL scans) for hasUnknownModelAICreditsError, mirroring what was done for hasAICreditsRateLimitError. Real unknown_model_ai_credits errors originate from the inference API and appear in gateway.log, stderr.log, or gateway.md.

@copilot please address this.

* @returns {boolean}
*/
function isAgenticEngineTimeout(logContent) {
// Always detect SDK idle-timeout (distinct from the step timeout).

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] The AGENTIC_ENGINE_TIMEOUT_PATTERN regex is stateful (lastIndex) but used with both .test() and the new isAgenticEngineTimeout function. Since it has no g flag here the lastIndex issue doesn't apply, but calling AGENTIC_ENGINE_TIMEOUT_PATTERN.test(logContent) inside isAgenticEngineTimeout then falling through to return true means a bare signal=SIGTERM in a non-process closed context (e.g. a process exit event line) will also be classified as a step timeout — even though that line alone cannot distinguish watchdog vs step.

💡 Suggested improvement

The fallthrough at line ~97 (return true when no watchdog-specific line is found) will fire on any SIGTERM that isn't on a process closed line. Consider narrowing the final fallback to only match process closed lines, or document explicitly that non-process-closed SIGTERMs are intentionally treated as step timeouts.

@copilot please address this.

});

it("detects max cache misses exceeded (JSON error type form)", () => {
const result = detectErrors('{"error":{"type":"max_cache_misses_exceeded","message":"Maximum consecutive cache misses exceeded (6 / 5).","consecutive_cache_misses":6,"max_cache_misses":5}}');

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 test for watchdogFired=false (line 554) uses a process closed line — good. But there is no test for a multiline log where a watchdog SIGTERM on attempt 1 is followed by a step-timeout SIGTERM on attempt 2 via detectErrors() (the public API). The isAgenticEngineTimeout unit tests cover this, but a detectErrors integration test for the mixed case would confirm the wiring is correct end-to-end.

💡 Suggested test
it('reports engine timeout when both watchdog and step-timeout SIGTERMs are present', () => {
  const log = [
    '[copilot-harness] attempt 1: process closed exitCode=1 signal=SIGTERM duration=10m watchdogFired=true',
    '[copilot-harness] attempt 2: process closed exitCode=1 signal=SIGTERM duration=20m watchdogFired=false',
  ].join('
');
  expect(detectErrors(log).agenticEngineTimeout).toBe(true);
});

@copilot please address this.

@pelikhan

pelikhan commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please address the remaining review feedback on this PR, then run the pr-finisher skill.

Outstanding signals to close:

  • Failed check: agenthttps://github.com/github/gh-aw/actions/runs/30745435666/job/91499106130
  • Recent maintainer prompt asks for pr-finisher after the current head update.
  • Review history still shows earlier requested-change feedback from automation around false-positive coverage / timeout detection; please verify the latest head fully addresses those concerns and close any remaining thread or follow-up explicitly.

Branch refresh was also requested for this PR. After updates, run the pr-finisher skill.

Run details: https://github.com/github/gh-aw/actions/runs/30750494960

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12 AIC · ⌖ 7.39 AIC · ⊞ 8.3K ·
Comment /souschef to run again

…SIGTERM detection

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Completed a PR-finisher pass in commit 093344b: addressed the unresolved review feedback with code and regression tests, ran local validation (make fmt, make lint, make test-unit, make test, make agent-report-progress), and pushed updates.

@pelikhan
pelikhan merged commit cd16b3b into main Aug 2, 2026
8 checks passed
@pelikhan
pelikhan deleted the copilot/aw-fix-daily-experiment-report branch August 2, 2026 14:05
Copilot stopped work on behalf of pelikhan due to an error August 2, 2026 14:05
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.3

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] daily-experiment-report hit AI credits rate limit

4 participants