@chatpanel/events 0.82.2 → 0.83.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/team-run.js +9 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/events",
3
- "version": "0.82.2",
3
+ "version": "0.83.0",
4
4
  "description": "The canonical ChatPanel event-log and capability contracts \u2014 typed durable facts, clock-free deterministic linearization, schema upcasting, and the invariants the replay harness asserts. Pure, dependency-free ESM shared by the ChatPanel extension, gateway and bridge.",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/team-run.js CHANGED
@@ -122,6 +122,11 @@ export async function runTeam({
122
122
  return (appoint ? appoint(r, { exclude }) : null) || (r.model && !exclude?.has(r.model) ? { model: r.model, mode: r.mode } : null);
123
123
  };
124
124
  const MAX_APPOINTMENTS = 3;
125
+ // A model that was not there for one member is not there for the next: what failed as
126
+ // unavailable anywhere in this run is skipped by every later appointment. Two members
127
+ // each spent two minutes finding out the same agent was down.
128
+ const runExclude = new Set();
129
+ const excluding = (local) => new Set([...runExclude, ...(local || [])]);
125
130
  const stopped = () => !!signal?.aborted;
126
131
 
127
132
  say(resume ? 'run.resumed' : 'run.started', { team: t.name, request: String(request || ''), budget: budget.cap, roles: t.roles.map((r) => r.id), ...(resume ? { carried: [...carried] } : {}) });
@@ -215,7 +220,7 @@ export async function runTeam({
215
220
  const exclude = new Set();
216
221
  let lastErr = '';
217
222
  for (let attempt = 1; ; attempt++) {
218
- const m = modelFor(role, exclude);
223
+ const m = modelFor(role, excluding(exclude));
219
224
  if (!m?.model) throw new Error(exclude.size ? `no model left for role "${role.id}" after ${[...exclude].join(', ')}` : `no model for role "${role.id}"`);
220
225
  if (attempt > 1) say('task.reappointed', { taskId: task.id, role: role.id, model: m.model, after: [...exclude], error: lastErr });
221
226
  // Who is doing this task, for a ledger that shows the lanes — said per attempt.
@@ -236,7 +241,7 @@ export async function runTeam({
236
241
  if (res?.ok && String(res?.text || '').trim()) { text = String(res.text); break; }
237
242
  const err = res?.ok ? 'the model returned no answer' : (res?.error || 'the model did not answer');
238
243
  if (attempt >= MAX_APPOINTMENTS || stopped() || !isModelUnavailable(err)) throw new Error(err);
239
- exclude.add(m.model); lastErr = err;
244
+ exclude.add(m.model); runExclude.add(m.model); lastErr = err;
240
245
  }
241
246
  }
242
247
  } catch (e) {
@@ -294,7 +299,7 @@ export async function runTeam({
294
299
  const excl = new Set();
295
300
  let judgeErr = '';
296
301
  for (let attempt = 1; attempt <= MAX_APPOINTMENTS; attempt++) {
297
- const mm = attempt === 1 ? m : modelFor(judge, excl);
302
+ const mm = attempt === 1 ? (runExclude.has(m?.model) ? modelFor(judge, excluding(excl)) : m) : modelFor(judge, excluding(excl));
298
303
  if (!mm?.model) break;
299
304
  if (attempt > 1) say('task.reappointed', { taskId: 'merge', role: judge.id, model: mm.model, after: [...excl], error: judgeErr });
300
305
  say('task.model', { taskId: 'merge', role: judge.id, model: mm.model, attempt });
@@ -303,7 +308,7 @@ export async function runTeam({
303
308
  if (res?.ok && String(res.text || '').trim()) break;
304
309
  const err = res?.ok ? 'the model returned no answer' : (res?.error || 'the model did not answer');
305
310
  if (stopped() || !isModelUnavailable(err)) break;
306
- excl.add(mm.model); judgeErr = err;
311
+ excl.add(mm.model); runExclude.add(mm.model); judgeErr = err;
307
312
  }
308
313
  const judged = res?.ok && String(res.text || '').trim();
309
314
  say(judged ? 'task.done' : 'task.failed', { taskId: 'merge', role: judge.id, status: judged ? 'ok' : 'failed', error: judged ? null : (res?.error || 'the judge did not answer'), findings: 0 });