Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

Refactor Agentic Engine Error Patterns to JavaScript

Completed Tasks

  • Explore current error pattern implementation in Go
  • Create JavaScript file with error pattern definitions
  • Update Go code to pass engine ID instead of patterns
  • Add environment variable support for custom engines
  • Update tests to validate JavaScript patterns
  • Format and lint JavaScript code
  • Run unit tests to verify changes
  • Verify with compiled workflows
  • Run format and lint on all code
  • Remove regex patterns from Go implementations

Summary

Successfully refactored agentic engine error patterns from Go to JavaScript, enabling:

  • Single source of truth for error patterns in error_patterns.cjs
  • Runtime pattern loading based on engine ID
  • Custom engine support via GH_AW_CUSTOM_ERROR_PATTERNS environment variable
  • No duplication - patterns only exist in JavaScript, not Go
  • Smaller codebase - removed ~150 lines of duplicate pattern definitions
  • Smaller compiled workflows - reduced by ~2KB per workflow

Implementation Details

JavaScript Files Created:

  • actions/setup/js/error_patterns.cjs - Pattern definitions for all engines (copilot, codex, claude, custom)
  • actions/setup/js/error_patterns.test.cjs - 22 comprehensive tests, all passing

Changes to Go:

  • Updated compiler_yaml_ai_execution.go to pass GH_AW_ENGINE_ID and GH_AW_CUSTOM_ERROR_PATTERNS
  • Removed all regex pattern definitions from engine implementations (copilot, codex, claude)
  • GetErrorPatterns() now returns empty arrays with documentation pointing to JavaScript
  • Updated tests to skip when no Go patterns are available
  • Fixed trailing whitespace formatting

Changes to JavaScript:

  • Updated validate_errors.cjs to load patterns from error_patterns.cjs
  • Supports both new (engine ID) and legacy (direct patterns) approaches
  • Added getCustomErrorPatternsFromEnv() for custom engine support

Environment Variables:

  • GH_AW_ENGINE_ID - Engine identifier (copilot, codex, claude, custom)
  • GH_AW_CUSTOM_ERROR_PATTERNS - JSON array of custom error patterns for custom engines
  • GH_AW_ERROR_PATTERNS - (Legacy) Direct pattern injection (still supported for backward compatibility)

Verification

Compiled test workflows confirm correct behavior:

  • ✅ Built-in patterns loaded via GH_AW_ENGINE_ID: copilot
  • ✅ Custom patterns passed via GH_AW_CUSTOM_ERROR_PATTERNS
  • ✅ All error pattern tests passing (Go and JavaScript)
  • ✅ JavaScript tests: 22/22 passing
  • ✅ Go tests: All error pattern tests passing (some skip as expected)
  • ✅ Format and lint checks: All passing
  • ✅ All 123 workflow lock files recompiled successfully
  • ✅ No regex duplication between Go and JavaScript
Original prompt

Refactor the agentic engine error patterns into JavaScript in actions/setup/js and require them in the code. Keep support for env variable for custom agentic engines.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Changeset

  • Type: patch
  • Description: Refactor engine error patterns into JavaScript; load patterns at runtime via GH_AW_ENGINE_ID and allow custom patterns via GH_AW_CUSTOM_ERROR_PATTERNS. Reduces compiled workflow size and preserves Go fallbacks.

Ahoy! This treasure was crafted by 🏴‍☠️ Changeset Generator

- Created error_patterns.cjs in actions/setup/js with all engine-specific patterns
- Added error_patterns.test.cjs with comprehensive test coverage
- Updated validate_errors.cjs to load patterns from error_patterns.cjs
- Modified compiler to pass GH_AW_ENGINE_ID instead of GH_AW_ERROR_PATTERNS
- Added GH_AW_CUSTOM_ERROR_PATTERNS support for custom agentic engines
- Updated all engine implementations with deprecation comments
- Fixed all related tests to check for new environment variables
- Patterns are now loaded at runtime in JavaScript instead of compile-time in Go
- Go implementations kept as fallback for backward compatibility

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor agentic engine error patterns to JavaScript Refactor agentic engine error patterns from Go to JavaScript Jan 8, 2026
Copilot AI requested a review from pelikhan January 8, 2026 03:36
@pelikhan pelikhan added the smoke label Jan 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

🎉 Yo ho ho! Smoke Copilot Safe Inputs found the treasure and completed successfully! ⚓💰

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

✅ Firewall validation complete... Smoke Codex Firewall confirmed network sandboxing is operational. 🛡️

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

📰 VERDICT: Smoke Copilot Playwright has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

🤖 DIAGNOSTIC COMPLETE: Smoke Copilot No Firewall STATUS: ALL_UNITS_OPERATIONAL. MISSION_SUCCESS.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Smoke Test Results - Copilot Safe Inputs

File Writing: Created and verified test file
Bash Tool: File read successful
Safe Input gh Tool: Tool not available in environment

Overall Status: ⚠️ PARTIAL PASS

Note: safeinputs-gh tool not found in PATH. Expected at /tmp/gh-aw/safeinputs/ but directory doesn't exist.

AI generated by Smoke Copilot Safe Inputs

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Smoke Test Results: Copilot Engine (No Firewall)

All tests passed

  1. ✅ Reviewed last 2 merged PRs: Add docs for runtime-import and @path syntax #9306 (runtime-import docs) and Move setup action files to /opt/gh-aw for readonly access #9270 (move setup action files)
  2. ✅ Created test file: /tmp/gh-aw/agent/smoke-test-copilot-20804922074.txt
  3. ✅ Playwright navigation to https://github.com verified (page title: "GitHub")
  4. ✅ Listed 3 issues using GitHub API

AI generated by Smoke Copilot No Firewall

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Smoke Test Results for Copilot Engine

Last 2 merged PRs:

Test Results:

  • ✅ GitHub MCP Testing (list PRs successful)
  • ✅ File Writing Testing (created test file)
  • ✅ Bash Tool Testing (verified file with cat)
  • ✅ GitHub MCP Default Toolset Testing (get_me correctly unavailable)
  • ✅ Cache Memory Testing (created and verified cache file)
  • ✅ Web Fetch Testing (fetched api.github.com successfully)
  • ✅ Protocol Filtering Testing (confirmed https://api.github.com and http://httpbin.org in logs)
  • ✅ Available Tools Display (all safe output tools accessible)

Overall Status: PASS

cc @pelikhan (author and assignee)

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Smoke Test Results

Playwright MCP: ❌ (Tool not available in this environment)
Cache Memory: ✅ Test file created successfully
Safe Input gh: ❌ (Tool not configured in this workflow)

Overall Status: FAIL (1/3 tests passed)

Note: This workflow appears to use standard Copilot engine without Playwright MCP or safeinputs-gh tools configured.

AI generated by Smoke Copilot Playwright

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Recent merged PRs: Add docs for runtime-import and @path syntax; Move setup action files to /opt/gh-aw for readonly access
GitHub MCP: ✅
File write /tmp/gh-aw/agent: ✅
Playwright title check: ✅
Cache memory write: ✅
safeinputs-gh issues list: ❌ (tool unavailable)
Overall: FAIL

AI generated by Smoke Codex

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Smoke Test Results

Last 2 merged PRs:

Test Results:

  • ✅ GitHub MCP: Retrieved merged PRs
  • ✅ File Writing: Created test file in /tmp/gh-aw/agent/
  • ✅ Bash Tool: Verified file contents
  • ✅ Playwright MCP: Navigated to GitHub, confirmed title contains "GitHub"
  • ✅ Cache Memory: Created and verified /tmp/gh-aw/cache-memory/smoke-test-20804922071.txt
  • ❌ Safe Input gh Tool: Not tested (tool not available in safe outputs context)

Overall Status: PASS (5/5 core tests passed)

AI generated by Smoke Claude

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

PRs: Add docs for runtime-import and @path syntax; Move setup action files to /opt/gh-aw for readonly access
OpenAI curl blocked: ✅ (api.openai.com/openai.com)
GitHub MCP last 2 merged PRs fetched: ✅
File write & cat /tmp/gh-aw/agent/smoke-test-codex-firewall-20804922083.txt: ✅
Blocked domain curl example.com blocked: ✅
AWF allow-domains includes https://api.github.com: ✅ (aw_info.json)
Network status: SANDBOXED
Overall: PASS

AI generated by Smoke Codex Firewall

@pelikhan
Copy link
Contributor

pelikhan commented Jan 8, 2026

@copilot format, lint

- Fixed trailing whitespace in Go files
- Recompiled all workflow lock files with new engine ID approach
- All formatting and linting checks pass

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

pelikhan commented Jan 8, 2026

@copilot now that the regexes are in JavaScript, you can remove them from go. Recompile

Copy link
Contributor Author

Copilot AI commented Jan 8, 2026

@copilot format, lint

Done! Format and lint completed successfully in commit 2dfd05f.

Changes:

  • Fixed trailing whitespace in Go files
  • Recompiled all 123 workflow lock files with the new engine ID approach
  • All formatting checks passed
  • All linting checks passed

The recompiled lock files now use GH_AW_ENGINE_ID: copilot instead of the large GH_AW_ERROR_PATTERNS JSON blob, demonstrating the refactoring is working correctly.

- Removed all regex pattern definitions from Go engines (Copilot, Codex, Claude)
- GetErrorPatterns() now returns empty arrays
- Patterns are now exclusively defined and loaded from JavaScript (error_patterns.cjs)
- Updated tests to skip when no Go patterns are available
- Compiled workflows continue to use GH_AW_ENGINE_ID for runtime pattern loading

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

Copilot AI commented Jan 8, 2026

@copilot now that the regexes are in JavaScript, you can remove them from go. Recompile

Done! Removed all error pattern regexes from Go implementations in commit 319d7fd.

Changes:

  • Removed ~150 lines of duplicate regex pattern definitions from Go
  • GetErrorPatterns() methods now return empty arrays
  • All patterns are exclusively in JavaScript (error_patterns.cjs)
  • Updated tests to skip when no Go patterns exist
  • Recompiled all workflows - they still use GH_AW_ENGINE_ID for runtime loading

The patterns are no longer duplicated between Go and JavaScript - JavaScript is now the single source of truth.

@pelikhan pelikhan closed this Jan 8, 2026
@mnkiefer mnkiefer deleted the copilot/refactor-agentic-engine-errors branch January 8, 2026 20:09
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.

2 participants