Skip to content

fix: detect max consecutive cache misses exceeded and surface dedicated failure context - #49070

Merged
pelikhan merged 4 commits into
mainfrom
copilot/aw-cli-version-checker-failure-fix
Jul 30, 2026
Merged

fix: detect max consecutive cache misses exceeded and surface dedicated failure context#49070
pelikhan merged 4 commits into
mainfrom
copilot/aw-cli-version-checker-failure-fix

Conversation

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

The max_cache_misses_exceeded error (HTTP 403) from the Anthropic API was not recognized by the failure handler, so affected runs produced the generic engine failure context instead of actionable guidance.

Changes

  • actions/setup/md/max_cache_misses_exceeded.md — new template with [!WARNING] alert plus two <details> blocks (cause explanation, remediation steps) for progressive disclosure; base error message is suppressed when this fires

  • actions/setup/js/handle_agent_failure.cjs — new ENGINE_MAX_CACHE_MISSES_EXCEEDED_RE regex matching both the JSON error type (max_cache_misses_exceeded) and the human-readable message (Maximum consecutive cache misses exceeded); new hasEngineMaxCacheMissesExceededSignal() / buildEngineMaxCacheMissesExceededContext() pair wired into buildEngineFailureContext() between the max-runs and generic error paths — early return suppresses the base error, consistent with the existing engine_rate_limit_429 and engine_max_runs_exceeded patterns

  • actions/setup/js/handle_agent_failure.test.cjs — 8 new tests covering empty input, JSON error type, human-readable message, exact production log line, unrelated content, template rendering, label fallback, and label whitespace trimming

Copilot AI linked an issue Jul 30, 2026 that may be closed by this pull request
…ed failure context

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CLI version checker engine failure fix: detect max consecutive cache misses exceeded and surface dedicated failure context Jul 30, 2026
Copilot AI requested a review from pelikhan July 30, 2026 06:59
@github-actions

Copy link
Copy Markdown
Contributor

Triage Summary

  • Category: bug
  • Risk: low
  • Priority Score: 48/100 (impact 25 + urgency 15 + quality 8)
  • Recommended Action: defer

Improves failure-handler messaging for max_cache_misses_exceeded errors. Still draft; no CI runs recorded yet.

Generated by 🔧 PR Triage Agent · auto · 54.9 AIC · ⌖ 5.64 AIC · ⊞ 7.9K ·

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot this is a common error generated by awf, look into the awf events logs and add a unified detection mechanism for all agentic engines.

…errors for all agentic engines

- Add MAX_CACHE_MISSES_EXCEEDED_EVENT_TYPE constant and parseMaxCacheMissesExceededFromEventLog()
  to ai_credits_context.cjs to detect structured max_cache_misses_exceeded events from the AWF
  API proxy event logs (engine-agnostic guardrail, all engines share the same proxy)

- Add MAX_CACHE_MISSES_EXCEEDED_PATTERN regex and isMaxCacheMissesExceededError() to
  detect_agent_errors.cjs — the unified detection module — covering both the agent stdio log
  (text pattern) and the AWF API proxy event log (structured events)

- Wire maxCacheMissesExceeded into detectErrors() return value, buildOutputLines()
  (max_cache_misses_exceeded output), and the main() stderr diagnostics

- Update handle_agent_failure.cjs to import MAX_CACHE_MISSES_EXCEEDED_PATTERN from
  detect_agent_errors.cjs instead of maintaining a duplicate regex

- Add 20 new tests to detect_agent_errors.test.cjs covering MAX_CACHE_MISSES_EXCEEDED_PATTERN,
  isMaxCacheMissesExceededError, detectErrors maxCacheMissesExceeded field, and
  buildOutputLines max_cache_misses_exceeded output

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

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot this is a common error generated by awf, look into the awf events logs and add a unified detection mechanism for all agentic engines.

Done in commit fix: add unified max_cache_misses_exceeded detection to detect_agent_errors for all agentic engines.

The max_cache_misses_exceeded error is generated by the AWF API proxy guardrail (apiProxy.maxCacheMisses), which is engine-agnostic — all engines (Claude, Copilot, Gemini, etc.) share the same proxy. The detection is now unified in detect_agent_errors.cjs with two sources checked:

  1. Agent stdio log — via MAX_CACHE_MISSES_EXCEEDED_PATTERN regex matching both the JSON error type (max_cache_misses_exceeded) and the human-readable message fragment
  2. AWF API proxy event logs — via parseMaxCacheMissesExceededFromEventLog() in ai_credits_context.cjs, scanning the same event-logs.jsonl paths used for unknown_model_ai_credits detection for structured {"type": "max_cache_misses_exceeded"} entries

The result is exposed as a max_cache_misses_exceeded GitHub Actions step output. handle_agent_failure.cjs now imports MAX_CACHE_MISSES_EXCEEDED_PATTERN from detect_agent_errors.cjs instead of maintaining a duplicate regex.

@pelikhan
pelikhan marked this pull request as ready for review July 30, 2026 08:05
Copilot AI review requested due to automatic review settings July 30, 2026 08:05

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

Adds dedicated failure context for AWF API proxy cache-miss limit failures.

Changes:

  • Detects cache-miss-limit signals in runtime and structured logs.
  • Renders actionable failure guidance instead of generic engine output.
  • Adds detector and template tests.
Show a summary per file
File Description
actions/setup/md/max_cache_misses_exceeded.md Adds failure guidance template.
actions/setup/js/handle_agent_failure.cjs Selects dedicated failure context.
actions/setup/js/handle_agent_failure.test.cjs Tests detection and rendering helpers.
actions/setup/js/detect_agent_errors.cjs Adds unified error detection and output.
actions/setup/js/detect_agent_errors.test.cjs Tests text detection and output generation.
actions/setup/js/ai_credits_context.cjs Detects structured proxy events.

Review details

Tip

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

  • Files reviewed: 6/6 changed files
  • Comments generated: 4
  • Review effort level: Medium

Comment on lines +2 to +9
> **Engine Cache Miss Limit Exceeded**: The {engine_label} engine hit the provider's consecutive cache miss limit and could not complete this run.

This signal was detected from engine runtime logs.

<details>
<summary>What caused this</summary>

The provider enforces a limit on consecutive cache misses. When too many back-to-back requests bypass the prompt cache, the API returns a 403 error and the engine terminates.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in a0f7e24. The template now attributes the failure to the gh-aw API proxy apiProxy.maxCacheMisses guardrail and the proxy's 403 max_cache_misses_exceeded response.

Comment on lines +2654 to +2657
if (hasEngineMaxCacheMissesExceededSignal(logContent)) {
core.info("Detected engine max cache misses signal — using dedicated context message");
return buildEngineMaxCacheMissesExceededContext(engineLabel);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in a0f7e24. Added buildEngineFailureContext coverage for cache-miss signals from both stdio and structured event logs, including suppression of the generic last-output context.

`http_400_response_error=${results.http400ResponseError}`,
`capi_quota_exceeded_error=${effectiveCAPIQuotaExceeded}`,
`invocation_cap_exceeded=${results.invocationCapExceeded}`,
`max_cache_misses_exceeded=${results.maxCacheMissesExceeded}`,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in a0f7e24. The detect-agent-errors output is now propagated through main job outputs and conclusion env wiring, and the handler also honors the structured event-log signal.

Comment on lines +443 to +450
function parseMaxCacheMissesExceededFromEventLog(eventLogPathOverride) {
return iterateJSONLFiles(
resolveUnknownModelAICreditsLogPaths(eventLogPathOverride),
false,
content => content.includes(MAX_CACHE_MISSES_EXCEEDED_EVENT_TYPE),
(acc, entry) => {
if (acc) return true; // already detected, short-circuit
return traverseObjectTree(entry, (_key, value) => value === MAX_CACHE_MISSES_EXCEEDED_EVENT_TYPE) || undefined;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in a0f7e24. Added direct parser coverage for parseMaxCacheMissesExceededFromEventLog, including primary and fallback event-log paths plus negative cases.

@github-actions

github-actions Bot commented Jul 30, 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 ≤100 new lines of code in business logic directories (0 additions detected in src/, lib/, pkg/, internal/, app/, core/, domain/, services/, api/).

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

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

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

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

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd — requesting changes on wiring gaps and test coverage.

📋 Key Themes

Issues

  • Missing downstream wiring (detect_agent_errors.cjs line 222): max_cache_misses_exceeded is emitted as a GitHub Actions output but is not consumed by addMainJobEngineErrorOutputs / buildAgentFailureEngineDetectionVars, so detection never reaches the failure context pipeline.
  • Missing integration test (handle_agent_failure.cjs line 2657): buildEngineFailureContext is not exercised through the new early-return branch — tests cover the detector and template builder individually but leave branch ordering and suppression untested.
  • Wrong attribution in user-facing template (max_cache_misses_exceeded.md line 9): The text attributes the limit to "the provider" but the guardrail is the AWF API proxy apiProxy.maxCacheMisses.
  • parseMaxCacheMissesExceededFromEventLog has no direct tests (ai_credits_context.cjs line 450): analogous parsers in this file have full event-log coverage.

Positive Highlights

  • ✅ Regex covers both observable forms (JSON error type + human-readable message)
  • ✅ Shared MAX_CACHE_MISSES_EXCEEDED_PATTERN avoids duplication between detector and failure handler
  • ✅ Template progressive disclosure is consistent with existing rate-limit and max-runs templates
  • ✅ Tests for hasEngineMaxCacheMissesExceededSignal and buildEngineMaxCacheMissesExceededContext are thorough

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

@github-actions

Copy link
Copy Markdown
Contributor

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Review Summary

This PR correctly models the max_cache_misses_exceeded detection after existing engine_rate_limit_429 / engine_max_runs_exceeded patterns, and the unit-test coverage for the regex and template builder is solid. However, four blocking issues (flagged in inline comments) prevent the implementation from working end-to-end:

  1. Template attribution (max_cache_misses_exceeded.md) — The message blames the provider, but the limit is enforced by the AWF API proxy (apiProxy.maxCacheMisses). Users will misread this as a third-party rate limit rather than a repo-configurable guardrail.

  2. Missing integration test (handle_agent_failure.cjs) — The new signal/context functions are unit-tested but there is no test exercising the full path through buildEngineFailureContext. Precedence relative to max-runs and the early-return/base-error-suppression are untested.

  3. Output not propagated (detect_agent_errors.cjs) — maxCacheMissesExceeded is emitted as a step output but addMainJobEngineErrorOutputs never declares it and buildAgentFailureEngineDetectionVars never passes it to the context builder. Detection fires but the result is silently dropped.

  4. Missing event-log parser tests (ai_credits_context.cjs) — parseMaxCacheMissesExceededFromEventLog has no test coverage despite the analogous parsers in the same file covering JSONL parsing, fallback paths, and unrelated entries.

Please address all four inline comments before merging.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 38.3 AIC · ⊞ 5.3K ·

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

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

test

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 38.3 AIC · ⊞ 5.3K

@github-actions

Copy link
Copy Markdown
Contributor

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

🧪 Test Quality Sentinel Report

Test Quality Score: 81/100 — Excellent

Analyzed 22 test(s) (new/modified, related to this PR): 21 design, 1 implementation, 0 violation(s).

📊 Metrics (22 tests)
Metric Value
Analyzed 22 (Go: 0, JS: 22)
✅ Design 21 (95%)
⚠️ Implementation 1 (5%)
Edge/error coverage 9 (41%)
Duplicate clusters 0
Inflation NO
🚨 Violations 0
Test File Classification Issues
MAX_CACHE_MISSES_EXCEEDED_PATTERN (4 cases) detect_agent_errors.test.cjs design_test · high_value
isMaxCacheMissesExceededError (4 cases) detect_agent_errors.test.cjs design_test · high_value
detectErrors max-cache-miss (4 cases) detect_agent_errors.test.cjs design_test · high_value
buildOutputLines max_cache_misses_exceeded (2 cases) detect_agent_errors.test.cjs design_test · high_value
hasEngineMaxCacheMissesExceededSignal (5 cases) handle_agent_failure.test.cjs design_test · high_value
buildEngineMaxCacheMissesExceededContext render+fallback (2 cases) handle_agent_failure.test.cjs design_test · high_value
buildEngineMaxCacheMissesExceededContext whitespace trim (1 case) handle_agent_failure.test.cjs implementation_test · low_value Tests internal trim() detail
⚠️ Flagged Tests (1)

buildEngineMaxCacheMissesExceededContext — trims leading/trailing whitespace from engine label (handle_agent_failure.test.cjs:3007) — implementation_test. Verifies that String.trim() is called internally rather than asserting a user-visible behavioral guarantee. Low risk at 5% ratio; no action required.

Verdict

passed. 5% implementation tests (threshold: 30%). Excellent coverage for the new max_cache_misses_exceeded detection feature: pattern-matching, JSON-error-type and human-readable-message forms, production-log fixtures, null/empty guards, output serialization, and context-rendering are all covered. Error-pattern safety is well exercised with negative cases across all new test groups.

References:

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 · 44.3 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: 81/100. 5% implementation tests (threshold: 30%).

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@copilot please run the pr-finisher skill, address the unresolved review feedback below, and fix the failing checks before rerunning CI.

Unresolved feedback to address (newest first):

Failed checks:

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 19.4 AIC · ⊞ 8.7K ·
Comment /souschef to run again

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

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

[!WARNING]
threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding....

Addressed in a0f7e24. I fixed the four unresolved review items, added the missing propagation/tests, and updated the affected wasm goldens. Local validation passed for make lint, targeted JS tests, go test ./pkg/workflow/..., TEST_UNIT_RUN_FULL=1 make test-unit, and make test. make agent-report-progress still reports a pre-existing check-workflow-drift failure from unrelated workflow lock drift on this branch, so CI on the new HEAD still needs a human re-trigger.

Copilot AI requested a review from gh-aw-bot July 30, 2026 09:23
@pelikhan
pelikhan merged commit c08fd30 into main Jul 30, 2026
37 checks passed
@pelikhan
pelikhan deleted the copilot/aw-cli-version-checker-failure-fix branch July 30, 2026 09:50
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@copilot please run the skill, address unresolved review feedback if any, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 9.62 AIC · ⊞ 8.7K ·
Comment /souschef to run again

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.1

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] CLI Version Checker failed

4 participants