Skip to content

[AI] Add skill to resolve failed backports#261080

Open
Ikuni17 wants to merge 10 commits intoelastic:mainfrom
Ikuni17:feature/failed-backport-skill
Open

[AI] Add skill to resolve failed backports#261080
Ikuni17 wants to merge 10 commits intoelastic:mainfrom
Ikuni17:feature/failed-backport-skill

Conversation

@Ikuni17
Copy link
Copy Markdown
Contributor

@Ikuni17 Ikuni17 commented Apr 3, 2026

Summary

Adds an agent skill for resolving failed backports caused by merge conflicts. When kibanamachine posts a backport failure comment on a merged PR, this skill guides the agent through:

  • Parsing the failure comment to identify which target branches failed
  • Running node scripts/backport locally with the failed branches
  • Resolving merge conflicts in the backport tool's working directory
  • Handling lock file conflicts via yarn kbn bootstrap instead of manual edits

Includes guardrails to bail out on non-trivial conflicts and report tool errors rather than retrying blindly.

Built with both Cursor + gpt-5.4-high and Claude.

Testing

Generated backports for these PRs with Cursor + gpt-5.4-high:
#259017
#259009

@Ikuni17 Ikuni17 self-assigned this Apr 3, 2026
@Ikuni17 Ikuni17 added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Apr 3, 2026
@Ikuni17 Ikuni17 marked this pull request as ready for review April 3, 2026 06:20
@Ikuni17 Ikuni17 requested a review from a team as a code owner April 3, 2026 06:20
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

cc @Ikuni17

```bash
SOURCE_SHA=$(gh api repos/elastic/kibana/pulls/<PR> --jq '.merge_commit_sha')

gh api --paginate --slurp repos/elastic/kibana/issues/<PR>/comments \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

testing this out, this command fails on my machine.

the `--slurp` option is not supported with `--jq` or `--template`

maybe it's a difference in the gh cli version? I'm running 2.79.0

```

Parse the markdown table in the latest matching `kibanamachine` comment to
extract branches with status "failed because of merge conflicts". These are the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what about backports that fail because there are prerequisites that may need to be merged ("you might need to backport the following PRs")? for example: #259467 (comment)

feels like that would be worth a mention


### Step 2: Run the backport tool

Run the backport from the **Kibana repo root**:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we have agents check for existing backports first, just in case one is already in flight? (I realize that's an edge case, might not be worth it)

Comment on lines +61 to +63
- If you want the backport tool to keep running while you resolve conflicts in
a separate shell, use any detached-session tool or second-terminal workflow
available on that machine. Do not assume `tmux` is installed.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this feels useful for humans but do agents need to know this? don't most agents already know how to run something in the background? (this is an honest question). is it better to just say that the backport tool is blocking and should be run in the background if you need to do other work in parallel?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants