Skip to content

Conversation

@jaceksan
Copy link

@jaceksan jaceksan commented Dec 3, 2025

Summary

This PR adds a new tool get_pull_request_ci_failures that allows AI agents to automatically find and retrieve CI failure logs for a pull request without manual copy-pasting from the GitHub web UI.

Use Case

When working with AI coding assistants like Cursor, GitHub Copilot, or Claude, a common workflow is:

  1. Create a PR with code changes
  2. CI pipeline runs and fails
  3. Currently: Manually navigate to GitHub Actions, find the failed job, copy error logs, paste into the AI chat
  4. With this tool: The AI agent can directly retrieve the failure logs and suggest fixes

This significantly improves the developer experience by eliminating the tedious copy-paste cycle when debugging CI failures.

Features

  • Finds workflow runs triggered by a PR using the head SHA
  • Identifies failed workflow runs (failure, timed_out, cancelled conclusions)
  • Collects logs from all failed jobs with failed step information
  • Returns log content by default (configurable via return_content parameter)
  • Supports tail_lines parameter to limit log output (default: 500 lines)

Implementation Details

  • Added GetPullRequestCIFailures function in pkg/github/actions.go
  • Added helper function getFailedJobsForRun to collect failed job logs for a workflow run
  • Reuses existing getJobLogData function for log retrieval
  • Registered in both pull_requests (default toolset) and actions toolsets
  • Comprehensive test coverage in pkg/github/actions_test.go

Tool Schema

{
  "name": "get_pull_request_ci_failures",
  "description": "Get failed CI workflow job logs for a pull request...",
  "inputSchema": {
    "required": ["owner", "repo", "pullNumber"],
    "properties": {
      "owner": { "type": "string" },
      "repo": { "type": "string" },
      "pullNumber": { "type": "number" },
      "return_content": { "type": "boolean", "default": true },
      "tail_lines": { "type": "number", "default": 500 }
    }
  }
}

Testing

  • All existing tests pass
  • Added unit tests for the new tool covering:
    • Successful CI failure retrieval with failed jobs
    • No failed workflow runs scenario
    • No workflow runs found scenario
    • Missing required parameters
    • PR not found error handling
    • Content return with actual log content

Checklist

  • Tests pass (go test ./...)
  • Linter passes (script/lint)
  • Documentation updated (script/generate-docs)
  • Toolsnap created

…for PRs

This tool allows AI agents to automatically find and retrieve CI failure logs
for a pull request without manual copy-pasting from the GitHub web UI.

Features:
- Finds workflow runs triggered by a PR using the head SHA
- Identifies failed workflow runs (failure, timed_out, cancelled)
- Collects logs from all failed jobs with failed step information
- Returns log content by default (configurable via return_content)
- Supports tail_lines parameter to limit log output

The tool is added to both pull_requests (default) and actions toolsets.
Copilot AI review requested due to automatic review settings December 3, 2025 19:54
@jaceksan jaceksan requested a review from a team as a code owner December 3, 2025 19:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new get_pull_request_ci_failures tool that enables AI agents to automatically retrieve CI failure logs for pull requests, eliminating the need for manual log extraction from the GitHub web UI. The tool finds workflow runs triggered by a PR's head SHA, identifies failed runs (failure, timed_out, cancelled), and collects logs from all failed jobs with step-level failure information.

Key changes:

  • New GetPullRequestCIFailures function and getFailedJobsForRun helper in pkg/github/actions.go
  • Tool registered in both pull_requests (default) and actions toolsets
  • Comprehensive test coverage including success cases, edge cases, and error handling

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/github/actions.go Implements new tool with PR lookup, workflow run filtering, and failed job log collection
pkg/github/actions_test.go Adds comprehensive test suite covering multiple scenarios including content retrieval
pkg/github/tools.go Registers new tool in both pull_requests and actions toolsets
pkg/github/toolsnaps/get_pull_request_ci_failures.snap Tool schema snapshot for API surface validation
README.md Documents new tool in both default and pull_requests toolset sections
docs/remote-server.md Updates toolset table (note: changes "Default" to "all" in first row)

jaceksan and others added 2 commits December 4, 2025 00:24
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

1 participant