ai-agentmanager 1.34.0 → 1.36.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,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.36.0 (2026-11-10)
4
+
5
+ - **Open sessions are always at the top of the agents list.** Agents needing your input come first, then working ones, then open sessions waiting for a prompt, in every list order. In **By project**, projects with an open session come first and, inside each project, open sessions come before the rest. The *last N days* filter no longer hides an older agent whose session is open. The **Running first** order is gone, since every order now does this; a saved choice falls back to **Recently used**.
6
+ - Fixed a flaky end-to-end test: the Eval's one-minute timer could redo an Eval the test had set by hand.
7
+
8
+ ## 1.35.0 (2026-11-09)
9
+
10
+ - **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.
11
+
3
12
  ## 1.34.0 (2026-11-08)
4
13
 
5
14
  - **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.36.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/app.js CHANGED
@@ -82,8 +82,9 @@ const saveRecent = () => {
82
82
  localStorage.setItem('agentmgr.recentDays', String(recent.days));
83
83
  } catch {}
84
84
  };
85
- // How the agents list is ordered: recently used (the default), running first or newest first, one list each; or grouped by project.
86
- const ORDERS = ['recent', 'running', 'created', 'project'];
85
+ // How the agents list is ordered: recently used (the default) or newest first, one list each; or grouped by project.
86
+ // In each, open sessions come first: needing you, working, then waiting for a prompt.
87
+ const ORDERS = ['recent', 'created', 'project'];
87
88
  let listOrder = (() => {
88
89
  try {
89
90
  const v = localStorage.getItem('agentmgr.listOrder');
@@ -988,8 +989,8 @@ const copyBtn = (value) => `<button class="link" data-copy="${esc(value)}" title
988
989
 
989
990
  // ------------------------------------------------------------------ list
990
991
 
991
- /** Agents waiting on you first, then running ones, then the rest. */
992
- const rank = (a) => (a.runtime.attention ? 0 : a.runtime.running ? 1 : 2);
992
+ /** Agents needing you first, then working ones, then open sessions waiting for a prompt, then the rest. */
993
+ const rank = (a) => (a.runtime.attention ? 0 : a.runtime.running && a.runtime.busy ? 1 : a.runtime.running ? 2 : 3);
993
994
 
994
995
  // Agents with no work and no input from you for a day sink below the active ones.
995
996
  const ACTIVE_MS = 24 * 3600 * 1000;
@@ -1063,12 +1064,12 @@ function projectGroups(list) {
1063
1064
  }
1064
1065
  const out = [...groups.values()];
1065
1066
  for (const g of out) {
1066
- // Active in the last day first; then highest priority, agents needing you, running ones, most recent.
1067
+ // Open sessions first (needing you, working, waiting); then active in the last day, highest priority, most recent.
1067
1068
  g.agents.sort(
1068
1069
  (a, b) =>
1070
+ rank(a) - rank(b) ||
1069
1071
  isActive(b) - isActive(a) ||
1070
1072
  (a.priority ?? 2) - (b.priority ?? 2) ||
1071
- rank(a) - rank(b) ||
1072
1073
  (b.activeAt ?? b.createdAt).localeCompare(a.activeAt ?? a.createdAt),
1073
1074
  );
1074
1075
  g.active = g.agents.filter(isActive).length;
@@ -1087,6 +1088,7 @@ function projectGroups(list) {
1087
1088
  return out.sort(
1088
1089
  (a, b) =>
1089
1090
  special(a) - special(b) ||
1091
+ (b.waiting + b.running > 0) - (a.waiting + a.running > 0) ||
1090
1092
  (b.active > 0) - (a.active > 0) ||
1091
1093
  a.top - b.top ||
1092
1094
  b.waiting - a.waiting ||
@@ -1095,12 +1097,11 @@ function projectGroups(list) {
1095
1097
  );
1096
1098
  }
1097
1099
 
1098
- /** One list, most recently used first (Running first: the running agents, then the rest; Newest first: by creation). */
1100
+ /** One list: open sessions first (needing you, working, waiting), then most recently used (Newest first: by creation). */
1099
1101
  const usedAt = (a) => a.activeAt ?? a.createdAt ?? '';
1100
1102
  function orderedAgents(list) {
1101
- const top = (a) => (listOrder === 'running' && !a.runtime.running ? 1 : 0);
1102
1103
  const at = listOrder === 'created' ? (a) => a.createdAt ?? '' : usedAt;
1103
- return [...list].sort((a, b) => top(a) - top(b) || at(b).localeCompare(at(a)));
1104
+ return [...list].sort((a, b) => rank(a) - rank(b) || at(b).localeCompare(at(a)));
1104
1105
  }
1105
1106
 
1106
1107
  /** The project picker: every project with agents, by name; a project that's gone falls back to all. */
@@ -1135,9 +1136,9 @@ function renderList() {
1135
1136
  .toLowerCase()
1136
1137
  .includes(filterText),
1137
1138
  );
1138
- // The open agent stays in the list even when it's older.
1139
+ // The open agent, and agents with an open session, stay in the list even when they're older.
1139
1140
  const since = recent.on ? Date.now() - recent.days * 86_400_000 : 0;
1140
- const shown = since ? list.filter((a) => a.id === selectedId || (Date.parse(a.createdAt) || 0) >= since) : list;
1141
+ const shown = since ? list.filter((a) => a.id === selectedId || rank(a) < 3 || (Date.parse(a.createdAt) || 0) >= since) : list;
1141
1142
  const hidden = list.length - shown.length;
1142
1143
  $('#recent-bar').hidden = agents.size === 0;
1143
1144
  $('#recent-on').checked = recent.on;
package/public/index.html CHANGED
@@ -99,9 +99,8 @@
99
99
  <input type="number" id="recent-days" min="1" max="3650" value="7" aria-label="Days"> days
100
100
  <span class="spacer"></span><span id="recent-hidden"></span>
101
101
  <select id="list-project" aria-label="Project" title="Show only one project's agents" hidden></select>
102
- <select id="list-order" aria-label="Order" title="Recently used: one list, the agents created or worked in most recently on top. Running first: running agents on top, most recently used first, then the rest. Newest first: by creation date, the newest on top. By project: grouped, busiest and most urgent first.">
102
+ <select id="list-order" aria-label="Order" title="Open sessions are always on top: needing you, then working, then waiting for a prompt. Below them, Recently used: the agents created or worked in most recently first. Newest first: by creation date, the newest first. By project: grouped, projects with open sessions first.">
103
103
  <option value="recent">Recently used</option>
104
- <option value="running">Running first</option>
105
104
  <option value="created">Newest first</option>
106
105
  <option value="project">By project</option>
107
106
  </select>
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/server.js CHANGED
@@ -90,7 +90,7 @@ const HOOK_PATH = '/api/hooks/agents';
90
90
  const REPORT_PATH = '/api/agentkit/report';
91
91
  const NO_REPO_KINDS = new Set(['general', 'assistant']);
92
92
 
93
- export async function startServer({ port = PORT, host = HOST } = {}) {
93
+ export async function startServer({ port = PORT, host = HOST, evalTimer = true } = {}) {
94
94
  ensureHome();
95
95
  const config = loadConfig();
96
96
  const store = new Store(paths.state);
@@ -176,7 +176,7 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
176
176
  transcript: (a) => (engineOf(a).id === 'claude' && a.workdir ? readTail(engineOf(a).sessionFile(a.workdir, a.sessionId)) : null),
177
177
  log: (m) => console.log(`[agentmgr] ${m}`),
178
178
  });
179
- evals.startTimer();
179
+ if (evalTimer) evals.startTimer();
180
180
  const races = new Races({ manager, store });
181
181
  const review = new Review({ manager });
182
182
  // The walkthrough explains the same diff the review screen shows.
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. */