Skip to content

Fix overly aggressive error patterns in Claude, Codex, and Copilot engines#1185

Merged
pelikhan merged 5 commits intomainfrom
copilot/tune-claude-error-patterns
Oct 3, 2025
Merged

Fix overly aggressive error patterns in Claude, Codex, and Copilot engines#1185
pelikhan merged 5 commits intomainfrom
copilot/tune-claude-error-patterns

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 3, 2025

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.*denied matched any occurrence of these keywords, even in informational contexts:

❌ FALSE POSITIVE: "The API returned 401 Unauthorized"
❌ FALSE POSITIVE: "This endpoint is forbidden without admin privileges"
❌ FALSE POSITIVE: "Permission was denied because the token expired"

These patterns triggered on:

  • Claude's reasoning/thinking text (e.g., "I'll check if the user is unauthorized...")
  • API response descriptions (e.g., "Received 403 Forbidden from server")
  • Informational context in logs
  • Documentation or explanatory text

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":

- Pattern: (?i)permission.*denied
+ Pattern: (?i)error.*permission.*denied

- Pattern: (?i)unauthorized  
+ Pattern: (?i)error.*unauthorized

- Pattern: (?i)forbidden
+ Pattern: (?i)error.*forbidden

Results

Before (False Positives):

"The API returned 401 Unauthorized"
  ❌ MATCHED - Generic pattern (too broad)

"Permission was denied because the token expired"
  ❌ MATCHED - Generic pattern (too broad)

After (Fixed):

"The API returned 401 Unauthorized"
  ✅ No match - Informational text correctly ignored

"Permission was denied because the token expired"
  ✅ No match - Informational text correctly ignored

"ERROR: unauthorized access attempt"
  ✅ MATCHED - Actual error correctly detected

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.*copilot

Testing

Added comprehensive test suite in pkg/workflow/error_pattern_tuning_test.go that verifies:

  • Patterns don't match informational text (prevents false positives)
  • Patterns still match actual errors (maintains error detection)
  • All three engines (Claude, Codex, Copilot) behave consistently

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

The error pattern in claude is overly aggressive.

Analyze the output of this run https://github.com/githubnext/repo-mind/actions/runs/18209359159 and tune the claude agentic engine error patterns.


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

Copilot AI and others added 4 commits October 3, 2025 00:57
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
Copilot AI requested a review from pelikhan October 3, 2025 01:08
@pelikhan pelikhan marked this pull request as ready for review October 3, 2025 01:09
@pelikhan pelikhan enabled auto-merge (squash) October 3, 2025 01:10
@pelikhan pelikhan disabled auto-merge October 3, 2025 01:11
@pelikhan pelikhan merged commit b2abf16 into main Oct 3, 2025
24 of 27 checks passed
@pelikhan pelikhan deleted the copilot/tune-claude-error-patterns branch October 3, 2025 01:12
Sign up for free to 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.

2 participants