ai-agentmanager 1.34.0 → 1.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.35.0 (2026-11-09)
4
+
5
+ - **Flaky CI is caught before it reaches the agent.** When GitHub Actions checks fail on an agent's pull request, the failed jobs are run once more on the same commit (`gh run rerun --failed`) before the agent is told. If they pass, the checks are marked **Flaky** on the pull request's row in the Land tab and nothing is sent; if they fail again, the agent is told, and that it failed twice. Checks from other CI systems, and a re-run GitHub refuses, go to the agent straight away as before. Once per commit; turn it off in the Land tab's settings.
6
+
3
7
  ## 1.34.0 (2026-11-08)
4
8
 
5
9
  - **Merge on the Eval.** A pull request is *sure to merge* when its agent's Eval is 100%, the app's own test run passed on the very commit the pull request is at with nothing left uncommitted, a reviewer approved it, and GitHub has it ready. The Land tab lists these first, marked **Sure to merge** with the Eval's percentage; a ready pull request that isn't sure says why (for example "The tests ran on a different commit than the pull request is at"). Turn on **Merge on the Eval** in the Land tab's settings and these merge on their own: each commit is tried once, your policies and branch protection still apply, and a merge that fails says why on the pull request's row. Off by default; the approval requirement can be turned off.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-agentmanager",
3
- "version": "1.34.0",
3
+ "version": "1.35.0",
4
4
  "description": "Run background coding agents (Claude Code, Codex) per intent, and keep track of them from a web UI, your phone or the CLI",
5
5
  "keywords": [
6
6
  "claude",
package/public/land.js CHANGED
@@ -50,6 +50,17 @@ export function initLand({ api, esc, toast, agents, $, scoreBadge = () => '', se
50
50
  return ` <span class="hint" title="Last sent ${esc(new Date(c.lastAt).toLocaleString())}">${c.count} review comment${c.count === 1 ? '' : 's'} sent</span>`;
51
51
  }
52
52
 
53
+ // Failed checks being run again before the agent hears of them, and checks that passed on a re-run.
54
+ function rerunHint(a, pr) {
55
+ const recs = Object.entries(a.landing?.reruns ?? {}).filter(([k]) => k.startsWith(`${pr.url}@`)).map(([, v]) => v);
56
+ const now = a.landing?.reruns?.[`${pr.url}@${pr.head}`];
57
+ const flaky = [...new Set(recs.filter((r) => r.result === 'passed').flatMap((r) => r.flaky ?? []))];
58
+ let out = '';
59
+ if (now && !now.result && !now.error) out += ` <span class="hint" title="The failed GitHub Actions jobs run once more before the agent is told">Re-running ${esc((now.checks ?? []).join(', ') || 'failed checks')}</span>`;
60
+ if (flaky.length) out += ` <span class="hint" title="Failed, then passed when run again on the same commit">Flaky: ${esc(flaky.join(', '))}</span>`;
61
+ return out;
62
+ }
63
+
53
64
  // Why a ready pull request isn't sure, or why merging it on its own didn't work.
54
65
  function sureHint(a, pr, land, sure) {
55
66
  const tried = a.landing?.sure?.[`${pr.url}@${pr.head}`];
@@ -63,7 +74,7 @@ export function initLand({ api, esc, toast, agents, $, scoreBadge = () => '', se
63
74
  return `<li class="agent land-row" data-agent="${a.id}" data-url="${esc(pr.url)}">
64
75
  <div class="line1"><span class="prio p${a.priority ?? 2}">P${a.priority ?? 2}</span>
65
76
  <a class="name" href="${esc(pr.url)}" target="_blank" rel="noopener" title="${esc(pr.title ?? pr.url)}">#${esc(pr.number ?? '')} ${esc(pr.title ?? pr.url)}</a></div>
66
- <div class="line2"><button class="link" data-land="goto">${esc(a.name)}</button>${a.runtime?.busy ? ' <span class="hint">working</span>' : ''}${commentsHint(a.landing?.comments?.[pr.url])}${sureHint(a, pr, land, sure)}</div>
77
+ <div class="line2"><button class="link" data-land="goto">${esc(a.name)}</button>${a.runtime?.busy ? ' <span class="hint">working</span>' : ''}${commentsHint(a.landing?.comments?.[pr.url])}${sureHint(a, pr, land, sure)}${rerunHint(a, pr)}</div>
67
78
  <div class="land-chips">${scoreBadge(a.docs?.scorecard, esc)} ${evalChip(a.eval, esc)} ${sure.sure ? `<span class="tag open" title="${esc(sure.why)}">Sure to merge</span>` : ''} ${prChips(pr, esc)}</div>
68
79
  <div class="bl-actions">
69
80
  <button class="small" data-land="review" title="Its diff, line comments for the agent, commit and push">Review</button>
@@ -97,6 +108,7 @@ export function initLand({ api, esc, toast, agents, $, scoreBadge = () => '', se
97
108
  : '<p class="hint land-empty">No open pull requests from agents. Open one from <b>Review changes</b> on an agent, or let the agent open it.</p>'}
98
109
  ${s ? `<details class="land-settings"><summary>When checks fail or reviewers comment</summary>
99
110
  <label class="check"><input type="checkbox" data-set="fixChecks" ${s.fixChecks ? 'checked' : ''}> Send failing checks to the agent</label>
111
+ <label class="check"><input type="checkbox" data-set="rerunFailed" ${s.rerunFailed ? 'checked' : ''}> First run failed GitHub Actions jobs once more on the same commit: one that passes then is marked flaky and not sent</label>
100
112
  <label class="check"><input type="checkbox" data-set="fixReviews" ${s.fixReviews ? 'checked' : ''}> Send requested changes to the agent</label>
101
113
  <label class="check"><input type="checkbox" data-set="fixComments" ${s.fixComments ? 'checked' : ''}> Send new review comments to the agent while the pull request is open (from the repo's members and review bots)</label>
102
114
  <label>At most <input type="number" min="0" max="20" data-set="maxFixes" value="${s.maxFixes}"> times per pull request</label>
package/src/landing.js CHANGED
@@ -2,7 +2,8 @@
2
2
  // back to the agent that owns the PR (a few times per PR at most), new review comments are sent
3
3
  // to it for as long as the PR is open, a branch that fell behind is brought up to date with the
4
4
  // branch it targets, and ready PRs are merged with one click. A PR whose Eval is 100% on its latest
5
- // commit is "sure": listed first, and merged on its own when that is turned on.
5
+ // commit is "sure": listed first, and merged on its own when that is turned on. Failed GitHub Actions
6
+ // checks are re-run once per commit before the agent hears of them: a check that passes then is flaky.
6
7
  import os from 'node:os';
7
8
  import * as git from './git.js';
8
9
  import { NO_REPO } from './manager.js';
@@ -12,12 +13,14 @@ import { parseBaseRef } from './review.js';
12
13
  import { sureToMerge as sureOf } from '../public/sure.js';
13
14
 
14
15
  export const MERGE_METHODS = ['squash', 'merge', 'rebase'];
15
- export const LANDING_DEFAULTS = { fixChecks: true, fixReviews: true, fixComments: true, maxFixes: 3, mergeMethod: 'squash', deleteBranch: true, mergeWhenSure: false, sureNeedsApproval: true };
16
+ export const LANDING_DEFAULTS = { fixChecks: true, fixReviews: true, fixComments: true, maxFixes: 3, mergeMethod: 'squash', deleteBranch: true, mergeWhenSure: false, sureNeedsApproval: true, rerunFailed: true };
16
17
  // Rounds of review comments sent per PR: a stop in case an agent's own replies keep coming back.
17
18
  const COMMENT_ROUNDS = 30;
18
19
  const QUOTE_MAX = 1500;
19
20
  const MESSAGE_MAX = 9000;
20
21
  const LAND_ORDER = ['ready', 'fix', 'behind', 'waiting', 'draft'];
22
+ // A re-run that GitHub hasn't been seen starting by then: take the failure as it stands.
23
+ const RERUN_WAIT_MS = 15 * 60_000;
21
24
 
22
25
  const err = (status, message) => Object.assign(new Error(message), { status });
23
26
 
@@ -34,14 +37,14 @@ export function landingSettings(config = {}) {
34
37
  deleteBranch: c.deleteBranch !== false,
35
38
  mergeWhenSure: c.mergeWhenSure === true,
36
39
  sureNeedsApproval: c.sureNeedsApproval !== false,
40
+ rerunFailed: c.rerunFailed !== false,
37
41
  };
38
42
  }
39
43
 
40
-
41
- export function checksMessage(pr) {
44
+ export function checksMessage(pr, { again = false } = {}) {
42
45
  const names = pr.checks?.failed?.length ? pr.checks.failed.join(', ') : 'some checks';
43
46
  return [
44
- `CI is failing on your pull request ${pr.url} (${names}).`,
47
+ `CI is failing on your pull request ${pr.url} (${names}).${again ? ' They were run again and failed again, so this is unlikely to be a flaky test.' : ''}`,
45
48
  `Look at the failures (\`gh pr checks ${pr.number ?? pr.url}\`, and \`gh run view <run id> --log-failed\` for the logs), fix the cause, run the relevant tests locally, then commit and push.`,
46
49
  'If a failure is unrelated to your change (a flaky test or a broken main), say so instead of changing unrelated code.',
47
50
  ].join('\n');
@@ -89,6 +92,13 @@ export function updateMessage(base) {
89
92
  return `Your branch is behind ${base}. Merge ${base} into it (git fetch, then git merge ${base}), resolve any conflicts keeping both sides' intent, run the tests, then commit and push.`;
90
93
  }
91
94
 
95
+ /** gh's --repo for a pull request's URL: owner/repo, with the host when it isn't github.com. */
96
+ export function repoOf(url) {
97
+ const m = /^https?:\/\/([^/]+)\/([^/]+)\/([^/]+)\/pull\/\d+/.exec(url ?? '');
98
+ if (!m) return null;
99
+ return m[1] === 'github.com' ? `${m[2]}/${m[3]}` : `${m[1]}/${m[2]}/${m[3]}`;
100
+ }
101
+
92
102
  /** sureToMerge with where the pull request stands worked out here. */
93
103
  export const sureToMerge = (agent, pr, opts = {}) => sureOf(agent, pr, { ...opts, land: landState(pr) });
94
104
 
@@ -145,6 +155,7 @@ export class Landing {
145
155
  for (const pr of this.openPrs(agent)) {
146
156
  const watched = s.fixComments ? await this.sendFeedback(agent, pr) : null;
147
157
  if (watched?.sent) sent = true;
158
+ if (this.trackRerun(agent, pr)) sent = true;
148
159
  if (!pr.head || !s.maxFixes) continue;
149
160
  const count = Object.keys(agent.landing.sent).filter((k) => k.startsWith(`${pr.url}#`)).length;
150
161
  if (count >= s.maxFixes) continue;
@@ -156,14 +167,68 @@ export class Landing {
156
167
  this.log(`landing: told ${agent.name} about ${kind} on ${pr.url}`);
157
168
  sent = true;
158
169
  };
159
- if (s.fixChecks && pr.checks?.state === 'failed') send('checks', checksMessage(pr));
170
+ if (s.fixChecks && pr.checks?.state === 'failed') {
171
+ const rerun = s.rerunFailed ? await this.rerunOnce(agent, pr) : null;
172
+ if (rerun?.started) sent = true;
173
+ if (!rerun?.waiting) send('checks', checksMessage(pr, { again: Boolean(rerun?.again) }));
174
+ }
160
175
  // A review requesting changes that comments are watched for was sent with them.
161
176
  else if (s.fixReviews && pr.review === 'CHANGES_REQUESTED' && !watched?.changesRequested) send('review', reviewMessage(pr));
162
177
  }
163
- if (sent) this.store.save();
178
+ if (sent && this.store.get(agent.id)) this.manager.patch(agent.id, { landing: agent.landing });
164
179
  await this.mergeIfSure(agent);
165
180
  }
166
181
 
182
+ /**
183
+ * Failed checks on this commit: re-run the failed GitHub Actions jobs once, and hold the message
184
+ * until they finish. { waiting } while they run, { again } when they failed again, null to tell
185
+ * the agent now (nothing to re-run, or the re-run couldn't start).
186
+ */
187
+ async rerunOnce(agent, pr) {
188
+ const key = `${pr.url}@${pr.head}`;
189
+ const reruns = (agent.landing.reruns ??= {});
190
+ const rec = reruns[key];
191
+ if (!rec) {
192
+ const runs = pr.checks?.runs ?? [];
193
+ const repo = repoOf(pr.url);
194
+ if (!runs.length || !repo) return null;
195
+ reruns[key] = { at: new Date().toISOString(), runs, checks: pr.checks.failed ?? [] };
196
+ try {
197
+ for (const id of runs) await git.run(ghBin(), ['run', 'rerun', id, '--failed', '--repo', repo], { cwd: os.tmpdir(), timeout: 60_000 });
198
+ } catch (e) {
199
+ reruns[key].error = e.message.replace(/^\S+ run rerun .*? failed: /, '');
200
+ this.log(`landing: couldn't re-run the failed checks on ${pr.url}: ${reruns[key].error}`);
201
+ return { started: true };
202
+ }
203
+ this.log(`landing: re-running the failed checks on ${pr.url} once before telling ${agent.name}`);
204
+ return { waiting: true, started: true };
205
+ }
206
+ if (rec.error) return null;
207
+ if (rec.result === 'failed') return { again: true };
208
+ // Still the failure from before the re-run: GitHub hasn't shown it starting yet.
209
+ if (!rec.restarted && Date.now() - Date.parse(rec.at) < RERUN_WAIT_MS) return { waiting: true };
210
+ rec.result = 'failed';
211
+ rec.doneAt = new Date().toISOString();
212
+ return { again: true };
213
+ }
214
+
215
+ /** A re-run under way: note when it starts, and a pass as flaky checks. True when something changed. */
216
+ trackRerun(agent, pr) {
217
+ const rec = agent.landing.reruns?.[`${pr.url}@${pr.head}`];
218
+ if (!rec || rec.result || rec.error) return false;
219
+ const state = pr.checks?.state;
220
+ if (state === 'running' && !rec.restarted) {
221
+ rec.restarted = true;
222
+ return true;
223
+ }
224
+ if (state === 'passed') {
225
+ Object.assign(rec, { result: 'passed', flaky: rec.checks, doneAt: new Date().toISOString() });
226
+ this.log(`landing: ${rec.checks.join(', ') || 'checks'} on ${pr.url} passed on a re-run: flaky`);
227
+ return true;
228
+ }
229
+ return false;
230
+ }
231
+
167
232
  /**
168
233
  * Merge the agent's pull requests that are sure to merge, when that is turned on. Tried once per
169
234
  * commit: a failure (a policy, branch protection) is kept and shown, not retried until it changes.
package/src/tracker.js CHANGED
@@ -226,19 +226,28 @@ const PR_FIELDS = 'number,title,url,state,isDraft,headRefOid,reviewDecision,merg
226
226
  const FAILED = new Set(['FAILURE', 'ERROR', 'TIMED_OUT', 'CANCELLED', 'ACTION_REQUIRED', 'STARTUP_FAILURE']);
227
227
  const PASSED = new Set(['SUCCESS', 'NEUTRAL', 'SKIPPED']);
228
228
 
229
- /** gh's statusCheckRollup -> { state: passed|failed|running|none, failed: [names], running, total } */
229
+ /**
230
+ * gh's statusCheckRollup -> { state: passed|failed|running|none, failed: [names], running, total },
231
+ * plus runs: the GitHub Actions run ids of the failed checks (when there are any), to re-run them.
232
+ */
230
233
  export function checkSummary(rollup) {
231
234
  const list = Array.isArray(rollup) ? rollup : [];
232
235
  const failed = [];
236
+ const runs = new Set();
233
237
  let running = 0;
234
238
  for (const c of list) {
235
239
  // Check runs have status/conclusion; commit statuses have state.
236
240
  const result = c.conclusion || (c.status && c.status !== 'COMPLETED' ? 'PENDING' : null) || c.state || 'PENDING';
237
- if (FAILED.has(result)) failed.push(c.name || c.context || 'check');
238
- else if (!PASSED.has(result)) running += 1;
241
+ if (FAILED.has(result)) {
242
+ failed.push(c.name || c.context || 'check');
243
+ const run = /\/actions\/runs\/(\d+)/.exec(c.detailsUrl ?? '')?.[1];
244
+ if (run) runs.add(run);
245
+ } else if (!PASSED.has(result)) running += 1;
239
246
  }
240
247
  const state = !list.length ? 'none' : failed.length ? 'failed' : running ? 'running' : 'passed';
241
- return { state, failed: failed.slice(0, 10), running, total: list.length };
248
+ const out = { state, failed: failed.slice(0, 10), running, total: list.length };
249
+ if (runs.size) out.runs = [...runs].slice(0, 5);
250
+ return out;
242
251
  }
243
252
 
244
253
  /** Where a pull request stands on its way in: merged, closed, draft, fix, behind, ready or waiting. */