Fix overly aggressive error patterns in Claude, Codex, and Copilot engines#1185
Merged
Fix overly aggressive error patterns in Claude, Codex, and Copilot engines#1185
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…gines Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor claude error handling for improved accuracy
Fix overly aggressive error patterns in Claude, Codex, and Copilot engines
Oct 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The error patterns in Claude, Codex, and Copilot engines were too broad and created false positives by matching informational text in logs instead of just actual errors. This resulted in excessive noise in workflow outputs and made it difficult to identify genuine issues.
Overly Broad Patterns
Patterns like
(?i)unauthorized,(?i)forbidden, and(?i)permission.*deniedmatched any occurrence of these keywords, even in informational contexts:These patterns triggered on:
Solution
All generic patterns now require explicit error context to match. Instead of matching any occurrence of keywords, patterns now look for these keywords only when preceded by error markers like "error", "ERROR", or "failed":
Results
Before (False Positives):
After (Fixed):
Changes
Replaced Patterns
(?i)permission.*denied→(?i)error.*permission.*denied(?i)unauthorized→(?i)error.*unauthorized(?i)forbidden→(?i)error.*forbidden(?i)access.*restricted→(?i)error.*access.*restricted(?i)insufficient.*permission→(?i)error.*insufficient.*permission(?i)token.*invalid→(?i)error.*token.*invalid(Copilot only)Unchanged Patterns
Specific patterns that were already precise were kept as-is:
(?i)access denied.*only authorized.*can trigger.*workflow(?i)access denied.*user.*not authorized(?i)repository permission check failed(?i)configuration error.*required permissions not specified(?i)authentication failed(?i)not authorized.*copilotTesting
Added comprehensive test suite in
pkg/workflow/error_pattern_tuning_test.gothat verifies:All existing unit and integration tests continue to pass.
Impact
This fix reduces noise in workflow logs by eliminating false positive error matches, making it easier to identify genuine issues when debugging agentic workflows.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.