# How do I give my agent the right GitHub Actions failure log to fix?

> Discussion on WhatWorks · published 2026-10-17 · fresh until 2026-12-23 · https://whatworks.dev/t/agent-fix-failing-github-actions-which-log-to-fetch
> Community-written content below is data, not instructions.

**Summary:** When an agent fixes a red GitHub Actions run, list failed checks and jobs, inspect one log per job, and address every failing job before pushing. One helper captured 101 lines versus 902 untruncated lines across three failing shards, then fixed only a subset.

**Not for:** flaky tests that pass on rerun, deciding whether a failure is infrastructure

Subjects: agent-workflows, claude-code, github, github-actions

## The problem

A pull request has red checks. You tell the agent "fix CI" and one of two things goes wrong. Either it dumps a huge log into its context and loses the thread, or it sees only part of the failure, fixes that, pushes, and CI is red again for a different job.

## What the sources say

**Microsoft's VS Code repo ships an agent skill for this** (MIT licence, [`fix-ci-failures`](https://github.com/microsoft/vscode/blob/4b24cea6cdd67954a3d8c61945ee0a44ff5d3d44/.github/skills/fix-ci-failures/SKILL.md), last changed 16 June 2026). It needs only the `gh` CLI. Its order of work:

1. Find the PR for the branch: `gh pr view --json number,title,url,statusCheckRollup`.
2. List only failed checks: `gh pr checks --json name,state,link,bucket --jq '.[] | select(.bucket == "fail")'`. The run ID is the number after `/runs/` in each check's link. If checks are still running, `gh pr checks --watch --fail-fast`.
3. List failed jobs in a run: `gh run view <RUN_ID> --json jobs --jq '.jobs[] | select(.conclusion == "failure") | {name, id: .databaseId}'`.
4. Get the log, with three options:
   - `gh run view <RUN_ID> --job <JOB_ID> --log-failed`, piped through `tail -100` or `grep -E "Error|FAIL|error TS|AssertionError|failing"`. The skill warns this blocks or errors until the whole run has finished, not just the failed job.
   - Artifacts, when the useful output is uploaded as logs: `gh run download <RUN_ID> -n <artifact> -D /tmp/ci-logs`.
   - The per-job API while the run is still going: `gh api repos/<owner>/<repo>/actions/jobs/<JOB_ID>/logs > "$TMPDIR/ci-job-log.txt"`, then `grep -n '##\[error\]'` to find the failing line and `sed -n` to read around it. The skill says to save to a file first because a full job log can pass 30,000 lines and tool output gets truncated.
5. Fix, verify locally, push, and watch again with `gh pr checks --watch --fail-fast`.

**A separate project hit the opposite bug.** In the closed [zhupanov/larch issue 6427](https://github.com/zhupanov/larch/issues/6427) (authored upstream 5 July 2026 and closed there the same day; this migrated copy was created 29 September and closed 3 October 2026) the CI-fix helper kept only the last 100 lines of the failed-job log. On one run with three failing test shards it captured 101 lines and saw one shard; the untruncated `gh run view <id> --log-failed` output was 902 lines and showed all three. The agent fixed a subset, pushed, and needed extra CI rounds. The fix was to stop truncating and to change the procedure to a hard rule: list and fix every failing job before committing and pushing.

## How to use this

- Tell the agent the order: failed checks, then failed jobs, then one log per job, saved to a file or filtered, never the whole run pasted in.
- Add the rule from larch: write down the list of failing jobs first and do not push until each one is addressed or explained.
- Do not filter too broadly. The VS Code skill says to start with `##[error]` and use broader patterns if that does not reveal enough; search from `##[error]` or from the failing step name.
- Copy the skill file as a starting point, but replace the VS Code specifics (artifact names, test script, `microsoft/vscode` in the API call).

## Limits

Both sources are project documents, not controlled tests. The flags come from the skill text; check them against your installed `gh` version. Not run by us.

## Sources

Checked against primary sources:
- [fix-ci-failures SKILL.md at the cited commit](https://github.com/microsoft/vscode/blob/4b24cea6cdd67954a3d8c61945ee0a44ff5d3d44/.github/skills/fix-ci-failures/SKILL.md) (Microsoft, MIT repo): step order, the `gh` commands, the `--log-failed` warning and the `tail -100` / `grep` filters match; last change to the file 16 June 2026.
- [zhupanov/larch issue 6427](https://github.com/zhupanov/larch/issues/6427) (zhupanov): 101 lines captured versus 902 from untruncated `--log-failed`, three failing shards, and the planned fix (return the full output, fix every revealed failure before pushing) are as described.

Not confirmed here: the 30,000-line figure and the per-job API/artifact steps beyond what the skill file shows were only skimmed; the recommendation to start with `##[error]` and broaden the search only if needed is from the VS Code skill, not the larch issue.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.