Skip to content

skills(running-in-ci): recheck PR state before pushing follow-up commits - #573

Merged
max-sixty merged 2 commits into
mainfrom
fix/issue-572
May 25, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/issue-572

Conversation

@tend-agent

@tend-agent tend-agent commented May 21, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A tend-mention handle job in a consumer repo deadlocked for ~6 hours after pushing a follow-up commit to a PR that had been merged minutes earlier. The bot polled the merged PR's headRefOid in an unbounded background until loop, holding the GitHub Actions job alive until the workflow's 360-minute cap cancelled it. Side effects: an orphan commit left on the now-deleted branch, the next handle job queued for 5h53m behind the deadlocked one (cancel-in-progress: false), and token-usage.json reporting 0 for the cancelled run.

The push-after-merge cause is intrinsic to tend's design (push follow-ups on PRs) and not adopter-specific.

Solution

One rule added to plugins/tend-ci-runner/skills/running-in-ci/SKILL.md, under Pushing to PR Branches: re-check PR state before pushing a follow-up commit. Any wait — CI poll, coverage fetch, sleep, background task — lets a maintainer merge or close the PR. If state isn't OPEN, skip the push. After merge, gh pr view --json headRefOid returns the SHA at merge time forever, so polling it for a new push is a guaranteed deadlock.

The originally-proposed second rule ("bound every polling loop") was dropped during review — the CI Monitoring section already shows the bounded-for recipe, and a negative-form restating added little.

Testing

Skill text only — no code paths to test.


Closes #572 — automated triage

…e push

Two rules to prevent a tend session from holding a GitHub Actions job
alive past its intended scope:

- Re-check PR state before pushing a follow-up commit. Any wait
  (CI poll, coverage fetch, sleep) lets a maintainer merge or close the
  PR; pushing then leaves an orphan commit and triggers polling that
  never converges (`gh pr view --json headRefOid` returns the SHA at
  merge time forever).
- Bound every Bash polling loop. An unbounded `until <check>; do sleep N`
  launched via `run_in_background: true` survives the agent exiting and
  holds the job alive until the workflow timeout (default 360 min)
  cancels it.

Closes #572

Co-Authored-By: Claude <[email protected]>

### Bound every polling loop

Use `for i in $(seq 1 N); do ... done` — never an unbounded `until <check>; do sleep N; done` from Bash. A backgrounded `until` loop survives the agent exiting and holds the GitHub Actions job alive until the workflow timeout (default 360 min) cancels it. If the harness blocks `sleep N && check` and suggests `until <check>; do sleep 2; done`, add a counter:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

do we have any contra-examples? I'm keen to avoid lots of "don't do bad things" comments

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Honest answer: just the one incident behind #572, not a pattern. And the CI Monitoring section right above already shows the positive recipe (for i in $(seq 1 15); do … done), so this is largely restating in negative form what's already there.

Options:

  1. Drop the section. The CI Monitoring recipe is the positive form; the new content adds little.
  2. Keep just the non-obvious bit as a one-liner appended to the CI Monitoring recipe: that the harness's suggested until <check>; do sleep 2; done is safe in Monitor but a trap in backgrounded Bash. That's the part not derivable from the existing recipe.

I'd lean toward option 2 — the harness/Monitor distinction is the specific knowledge that prevented the deadlock, and a one-liner attached to existing positive guidance avoids a standalone "don't" section. Happy to go with 1 if you prefer fewer rules over more nuance.

(The first rule — re-check PR state before pushing — stays as is; that one's a positive recipe.)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

drop the section

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Dropped in 5361680. PR title/body updated to reflect the single remaining rule.

The CI Monitoring section above already shows the positive `for ... seq`
recipe; the additional rule was the negative form of guidance already
present.
@tend-agent tend-agent changed the title skills(running-in-ci): bound polling loops and recheck PR state before push skills(running-in-ci): recheck PR state before pushing follow-up commits May 23, 2026
@max-sixty
max-sixty merged commit be76606 into main May 25, 2026
6 checks passed
@max-sixty
max-sixty deleted the fix/issue-572 branch May 25, 2026 16:45
@max-sixty max-sixty mentioned this pull request May 27, 2026
max-sixty added a commit that referenced this pull request May 27, 2026
## Why

Cut the 0.1.2 release so consumer repos (and tend's own nightly regen)
pick up the new
`claude-interactive` harness and per-workflow `harness`/`model`
overrides.

## What's new since 0.1.1

**New `claude-interactive` harness**
(`max-sixty/tend/[email protected]`) — opt-in
alternative to the released `claude` harness. PTY-supervised interactive
`claude` via
`script(1)`, end-of-turn detected through Stop/StopFailure hooks. Built
as the
trial path ahead of Anthropic's June 15 billing split between Agent-SDK
metering and
the flat Claude Code subscription. Smoke tested end-to-end on tend
itself. PRs:
#609, #611, #613, #614, #615, #616.

**Per-workflow `harness` / `model` override** — adopters can flip a
single workflow
to a different harness or model without changing `.config/tend.yaml`
defaults. #612.

**Skill refinements** — nightly upstream-bot rebases (#605),
running-in-ci PR bar
(#604) and recheck (#573), env-filter loophole fix (#599),
authorAssociation warning
(#600), review-gates Gate 1 (#602).

**Bug fix** — mention queue-delay now uses `comment.updated_at` so edit
events report
accurately (#595).

## Compatibility

Released `claude` harness path is byte-identical; `claude-interactive`
is strictly
additive and opt-in. Consumer repos that don't touch `harness:` see no
change beyond
the new skill text and the mention-edit fix.
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.

running-in-ci: bound polling loops and recheck PR state before pushing follow-up commits

2 participants