Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 21, 2026

Investigation: Agent not calling create-pull-request

Problem Analysis

  • Investigated workflow run 21191975136
  • Analyzed job logs and identified step 9 (Process Safe Outputs)
  • Found that agent reported missing_tool error
  • Traced through safe-outputs handler code
  • Identified root cause in error handling

Root Cause

When the create_pull_request safe-output tool fails (e.g., when patch generation fails because no commits were made), the handler throws an Error instead of returning an error response. This causes the MCP tool call to fail, but Claude Code CLI doesn't properly display MCP error responses - it just fails silently. The agent interprets this as the tool not existing and reports it as a "missing_tool".

Code Location: actions/setup/js/safe_outputs_handlers.cjs lines 231-236

Solution Implemented

  • Changed createPullRequestHandler to return error responses instead of throwing
  • Changed pushToPullRequestBranchHandler to return error responses instead of throwing
  • Added helpful error messages explaining the issue
  • Set isError: true flag in response
  • All JavaScript tests pass (2890 tests, +4 new tests)
  • Added comprehensive unit tests for error handling
  • Created test workflow to verify fix
  • Merged main branch
  • Format and lint passed

Files Modified

  • actions/setup/js/safe_outputs_handlers.cjs - Fixed error handling in both handlers
  • actions/setup/js/safe_outputs_handlers.test.cjs - Added 4 new tests for error handling
  • .github/workflows/test-create-pr-error-handling.md - Test workflow
  • .github/workflows/test-create-pr-error-handling.lock.yml - Compiled test workflow

Testing

  • Unit tests pass: npm test - 143 test files, 2890 tests passed
  • Added 4 new tests to verify error handling behavior:
    • createPullRequestHandler > should return error response when patch generation fails (not throw)
    • createPullRequestHandler > should include helpful details in error response
    • pushToPullRequestBranchHandler > should return error response when patch generation fails (not throw)
    • pushToPullRequestBranchHandler > should include helpful details in error response
  • Tests verify handlers return error responses instead of throwing exceptions
  • Tests verify error messages include actionable guidance (git add, git commit)
  • Created test workflow test-create-pr-error-handling
  • Merged main branch successfully
  • Format validated: make fmt - All files formatted
  • Lint validated: make lint - 0 issues
  • Manual testing: Run test workflow to verify agent receives clear error
  • Verify agent no longer reports "missing_tool" for patch generation failures

Next Steps

The test workflow can be manually triggered to verify that:

  1. The agent receives a clear error message when patch generation fails
  2. The error message explains that no commits were found
  3. The agent does NOT report it as a "missing_tool"

Custom agent used: agentic-workflows
GitHub Agentic Workflows (gh-aw) - Create, debug, and upgrade AI-powered workflows with intelligent prompt routing

Original prompt

Reference: https://github.com/githubnext/gh-aw/actions/runs/21191975136/job/60960418126#step:9:1

Investigate why the agent did not call create-pull-request? Something is broken.

Custom agent used: agentic-workflows
GitHub Agentic Workflows (gh-aw) - Create, debug, and upgrade AI-powered workflows with intelligent prompt routing


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 21, 2026 00:44
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…st_branch

When patch generation fails, return error response instead of throwing.
This ensures Claude Code CLI can properly display the error to the agent,
instead of the tool call failing silently.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
This workflow tests that the agent receives clear error messages
when create_pull_request fails, instead of treating it as a missing tool.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate failure to call create-pull-request method Fix MCP error handling in create_pull_request handlers Jan 21, 2026
Copilot AI requested a review from pelikhan January 21, 2026 00:55
@pelikhan
Copy link
Contributor

@copilot merge main, format lint

Copy link
Contributor Author

Copilot AI commented Jan 21, 2026

@copilot merge main, format lint

Merged main branch in commit 53c3d58. Format and lint passed with 0 issues.

@pelikhan
Copy link
Contributor

@copilot add tests

@pelikhan pelikhan marked this pull request as ready for review January 21, 2026 05:01
…r and pushToPullRequestBranchHandler

Tests verify that handlers return error responses (not throw) when patch generation fails,
and that error responses include helpful details for users.

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

Copilot AI commented Jan 21, 2026

@copilot add tests

Added comprehensive tests for error handling in commit 4d3fbc8. Added 4 new tests that verify:

  • Handlers return error responses instead of throwing exceptions
  • Error responses include helpful guidance for users
  • Error messages contain actionable instructions (git add, git commit)

All 2890 tests pass.

@pelikhan pelikhan merged commit 66fee63 into main Jan 21, 2026
82 checks passed
@pelikhan pelikhan deleted the copilot/investigate-create-pull-request-issue branch January 21, 2026 05:08
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