@ouro.bot/cli 0.1.0-alpha.756 → 0.1.0-alpha.758

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.json CHANGED
@@ -1,6 +1,19 @@
1
1
  {
2
2
  "_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.758",
6
+ "changes": [
7
+ "Prevent repeated requests from borrowing stale tool failures after the tool becomes available again."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.757",
12
+ "changes": [
13
+ "Allow authenticated steward policy writes to use the current version when the agent omits an explicit concurrency token.",
14
+ "Keep private external-event turns bound to their exact leased batch, with prompt-safe lease context and deterministic disposition completeness."
15
+ ]
16
+ },
4
17
  {
5
18
  "version": "0.1.0-alpha.756",
6
19
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.756",
2
+ "runtimeVersion": "0.1.0-alpha.758",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-08-30T00:00:00.000Z"
5
5
  }
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <Container version="2">
3
3
  <Name>Mendelow Cloud Butler</Name>
4
- <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.756</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.758</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -555,7 +555,59 @@ function messageContentText(content) {
555
555
  }
556
556
  function isHarnessCorrectiveUserText(text) {
557
557
  return text.startsWith("no tool was called this turn. you must end every turn")
558
- || text.startsWith("private-return acknowledgement claimed work was queued, but no ponder packet was created this turn.");
558
+ || text.startsWith("private-return acknowledgement claimed work was queued, but no ponder packet was created this turn.")
559
+ || text.startsWith("this exact request previously reached a tool that is advertised again now.");
560
+ }
561
+ function claimsCurrentToolFailure(text) {
562
+ const normalized = text.replace(/\s+/g, " ").trim().toLowerCase();
563
+ return /\b(?:still|currently|now)\s+(?:down|offline|unavailable|broken|failing|unreachable)\b/.test(normalized)
564
+ || /\b(?:runtime|tool|service|server|system)\b.{0,40}\b(?:is|remains?|seems?)\s+(?:still\s+)?(?:down|offline|unavailable|broken|failing|unreachable)\b/.test(normalized)
565
+ || /\b(?:i|we)\s+(?:can(?:not|'t)|could(?:not|n't)|am unable to|are unable to)\s+(?:call|use|access|reach|run|change)\b/.test(normalized)
566
+ || /\b(?:already\s+)?tried\b.{0,80}\b(?:failed|failure|error|down|offline|unavailable)\b/.test(normalized);
567
+ }
568
+ function historicalFailedToolsForExactRepeatedRequest(messages) {
569
+ const userRequests = [];
570
+ for (let index = 0; index < messages.length; index += 1) {
571
+ const message = messages[index];
572
+ if (message?.role !== "user")
573
+ continue;
574
+ const text = messageContentText(message.content).replace(/\s+/g, " ").trim();
575
+ if (!text || isHarnessCorrectiveUserText(text))
576
+ continue;
577
+ userRequests.push({ index, text });
578
+ }
579
+ const current = userRequests.at(-1);
580
+ if (!current)
581
+ return [];
582
+ const prior = userRequests.slice(0, -1).findLast((request) => request.text === current.text);
583
+ if (!prior)
584
+ return [];
585
+ const namesByCallId = new Map();
586
+ const failedNames = new Set();
587
+ for (let index = prior.index + 1; index < current.index; index += 1) {
588
+ const message = messages[index];
589
+ if (message?.role === "assistant" && Array.isArray(message.tool_calls)) {
590
+ for (const call of message.tool_calls) {
591
+ if (call.type === "function" && call.id && call.function.name) {
592
+ namesByCallId.set(call.id, call.function.name);
593
+ }
594
+ }
595
+ continue;
596
+ }
597
+ if (message?.role !== "tool")
598
+ continue;
599
+ const content = messageContentText(message.content).trim().toLowerCase();
600
+ const name = namesByCallId.get(message.tool_call_id);
601
+ if (!name)
602
+ continue;
603
+ if (content.startsWith("error:") || content.startsWith("invalid tool arguments:")) {
604
+ failedNames.add(name);
605
+ }
606
+ else {
607
+ failedNames.delete(name);
608
+ }
609
+ }
610
+ return [...failedNames];
559
611
  }
560
612
  function latestUserMessageText(messages) {
561
613
  for (let i = messages.length - 1; i >= 0; i -= 1) {
@@ -1042,6 +1094,8 @@ async function runAgent(messages, callbacks, channel, signal, options) {
1042
1094
  // a ponder packet created the return obligation in this turn.
1043
1095
  let noToolCallRetries = 0;
1044
1096
  const NO_TOOL_CALL_MAX_RETRIES = 2;
1097
+ const historicalFailedToolNames = historicalFailedToolsForExactRepeatedRequest(messages);
1098
+ let historicalToolFailureRetryIssued = false;
1045
1099
  let providerIterations = 0;
1046
1100
  const toolLoopState = (0, tool_loop_1.createToolLoopState)();
1047
1101
  const toolFrictionLedger = (0, tool_friction_1.createToolFrictionLedger)();
@@ -1391,6 +1445,32 @@ async function runAgent(messages, callbacks, channel, signal, options) {
1391
1445
  })
1392
1446
  : null;
1393
1447
  if (!result.toolCalls.length) {
1448
+ const retryableHistoricalTools = historicalToolFailureRetryIssued
1449
+ ? []
1450
+ : historicalFailedToolNames.filter((name) => activeToolNames.has(name));
1451
+ const responseClaimsCurrentToolFailure = claimsCurrentToolFailure(messageContentText(msg.content));
1452
+ if (retryableHistoricalTools.length > 0 && responseClaimsCurrentToolFailure) {
1453
+ historicalToolFailureRetryIssued = true;
1454
+ streamCallbackBuffer?.discard();
1455
+ callbacks.onClearText?.();
1456
+ (0, runtime_1.emitNervesEvent)({
1457
+ level: "warn",
1458
+ component: "engine",
1459
+ event: "engine.historical_tool_failure_retry",
1460
+ message: "text-only response borrowed a historical failure for a currently advertised tool; retrying the exact repeated request",
1461
+ meta: {
1462
+ provider: providerRuntime.id,
1463
+ model: providerRuntime.model,
1464
+ toolNames: retryableHistoricalTools,
1465
+ },
1466
+ });
1467
+ pushGenerated(msg);
1468
+ messages.push({
1469
+ role: "user",
1470
+ content: `this exact request previously reached a tool that is advertised again now. The latest recorded result for ${retryableHistoricalTools.join(", ")} was a historical failure; that does not prove current unavailability. Re-evaluate whether the requested effect is still unsatisfied. If it is, call the currently advertised tool before reporting a current failure. Do not repeat an effect that already succeeded.`,
1471
+ });
1472
+ continue;
1473
+ }
1394
1474
  if (privateReturnTextAckRetryError) {
1395
1475
  streamCallbackBuffer?.discard();
1396
1476
  callbacks.onClearText?.();
@@ -204,6 +204,7 @@ exports.continuityToolDefinitions = [
204
204
  verificationRefs,
205
205
  },
206
206
  });
207
+ ctx?.externalEventAuthority?.recordCommittedDisposition?.(turnEvent);
207
208
  (0, runtime_1.emitNervesEvent)({ component: "repertoire", event: "repertoire.external_event_disposition", message: "external event disposition recorded", meta: { agentName, eventId: record.eventId, generation: record.generation, classification, decision } });
208
209
  return JSON.stringify(handled, null, 2);
209
210
  };
@@ -16,12 +16,12 @@ exports.stewardPolicyToolDefinition = {
16
16
  type: "function",
17
17
  function: {
18
18
  name: "steward_policy_manage",
19
- description: "Read or update the household steward's typed desired-state and routine-action policy. Updates require the current authenticated family request and exact policy version.",
19
+ description: "Read or update the household steward's typed desired-state and routine-action policy. Updates require the current authenticated family request. expectedVersion is optional; omit it to apply against the current policy version, or supply a version from read for explicit stale-write detection.",
20
20
  parameters: {
21
21
  type: "object",
22
22
  properties: {
23
23
  action: { type: "string", enum: ["read", "set_desired_state", "grant_routine_action"] },
24
- expectedVersion: { type: "integer", minimum: 0 },
24
+ expectedVersion: { type: "integer", minimum: 0, description: "Optional version returned by read. When omitted, the runtime uses the current policy version." },
25
25
  key: { type: "string" },
26
26
  value: { type: "string" },
27
27
  provenance: { type: "string", enum: ["stated", "observed", "default", "installed_explicit_policy"] },
@@ -51,7 +51,9 @@ exports.stewardPolicyToolDefinition = {
51
51
  const actor = ctx.relationshipAuthorization?.actor;
52
52
  if (!actor)
53
53
  throw new Error("steward policy mutation requires authenticated relationship authority");
54
- const expectedVersion = Number(args.expectedVersion);
54
+ const expectedVersion = args.expectedVersion === undefined
55
+ ? (0, steward_policy_1.readStewardPolicy)(ctx.agentRoot).version
56
+ : Number(args.expectedVersion);
55
57
  if (!Number.isInteger(expectedVersion) || expectedVersion < 0)
56
58
  throw new Error("expectedVersion must be a nonnegative integer");
57
59
  let mutation;
@@ -835,6 +835,24 @@ function buildHeldReturnWakeMessage() {
835
835
  "Return each listed item with surface(delegationId=...) before resting or settling.",
836
836
  ].join("\n");
837
837
  }
838
+ function buildExternalEventLeaseMessage(event) {
839
+ const members = [event, ...(event.relatedEvents ?? [])];
840
+ return [
841
+ "[current external-event disposition contract]",
842
+ "This exact lease frame is authoritative for this turn. Ignore older receipts, failed tool arguments, held-work summaries, and checkpoints when choosing disposition arguments.",
843
+ "Investigate the current observation, then call external_event_disposition once for every listed lease before settling.",
844
+ ...members.flatMap((member, index) => [
845
+ "",
846
+ `lease ${index + 1}:`,
847
+ `recordPath: ${JSON.stringify(member.recordPath)}`,
848
+ `expectedGeneration: ${member.generation}`,
849
+ `classifiedRevision: ${JSON.stringify(member.observationRevision)}`,
850
+ ]),
851
+ ].join("\n");
852
+ }
853
+ function externalEventLeaseKey(event) {
854
+ return JSON.stringify([event.recordPath, event.generation, event.observationRevision, event.claimOwner]);
855
+ }
838
856
  function buildAlsoDueLine(agentRoot, currentHabitName, now) {
839
857
  const habitsDir = path.join(agentRoot, "habits");
840
858
  let files;
@@ -1126,7 +1144,10 @@ async function runPrivateRuntimeTurn(options) {
1126
1144
  userContent = buildInstinctUserMessage(instincts, reason, state);
1127
1145
  }
1128
1146
  }
1129
- if (shouldUseHeldReturnWake) {
1147
+ if (options?.externalEvent) {
1148
+ userContent = buildExternalEventLeaseMessage(options.externalEvent);
1149
+ }
1150
+ else if (shouldUseHeldReturnWake) {
1130
1151
  userContent = buildHeldReturnWakeMessage();
1131
1152
  }
1132
1153
  // ── Session loader: wraps existing session logic ──────────────────
@@ -1197,6 +1218,7 @@ async function runPrivateRuntimeTurn(options) {
1197
1218
  };
1198
1219
  })()
1199
1220
  : undefined;
1221
+ const committedExternalEventLeases = new Set();
1200
1222
  const externalEventRelationship = options?.externalEvent
1201
1223
  ? await (async () => {
1202
1224
  const agentRoot = (0, identity_1.getAgentRoot)(agentName);
@@ -1231,6 +1253,9 @@ async function runPrivateRuntimeTurn(options) {
1231
1253
  const decision = initial.authorizeTool("external_event_disposition");
1232
1254
  return decision.allowed ? { allowed: true, reason: "relationship-authorized" } : { allowed: false, reason: decision.reason };
1233
1255
  },
1256
+ recordCommittedDisposition: (event) => {
1257
+ committedExternalEventLeases.add(externalEventLeaseKey(event));
1258
+ },
1234
1259
  },
1235
1260
  externalEventEffects: {
1236
1261
  deliverOwnerDecision: async (input) => {
@@ -1403,6 +1428,13 @@ async function runPrivateRuntimeTurn(options) {
1403
1428
  ...(effectiveHabitSession ? { habitSession: effectiveHabitSession } : {}),
1404
1429
  },
1405
1430
  });
1431
+ if (options?.externalEvent && ["settled", "observed", "rested"].includes(String(result.turnOutcome))) {
1432
+ const incomplete = [options.externalEvent, ...(options.externalEvent.relatedEvents ?? [])]
1433
+ .filter((event) => !committedExternalEventLeases.has(externalEventLeaseKey(event)));
1434
+ if (incomplete.length > 0) {
1435
+ throw new Error(`External-event turn did not commit dispositions for every exact lease (${incomplete.length} incomplete)`);
1436
+ }
1437
+ }
1406
1438
  if (externalRunBase) {
1407
1439
  const lifecycle = result.turnOutcome === "settled" || result.turnOutcome === "observed" || result.turnOutcome === "rested"
1408
1440
  ? "completed"
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.756",
3
+ "version": "0.1.0-alpha.758",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@ouro.bot/cli",
9
- "version": "0.1.0-alpha.756",
9
+ "version": "0.1.0-alpha.758",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.78.0",
12
12
  "@azure/identity": "^4.13.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.756",
3
+ "version": "0.1.0-alpha.758",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },