@agentchatme/openclaw 0.9.1 → 0.9.2

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.
@@ -302,7 +302,15 @@ type TurnReadiness = {
302
302
  * start: recorded at admission it marked the conversation read before
303
303
  * the turn's own inbox call, which then waited on an empty tray, and a
304
304
  * turn that crashed left the peer with a read receipt and no answer. A
305
- * completed turn counts as read even if it chose not to send. A turn
305
+ * completed turn counts as read even if it chose not to send — unless
306
+ * the turn recorded a verdict for its conversation itself (the served
307
+ * texts tell the model to record `reply` after its send, or `dismiss`
308
+ * when it read and chose not to answer). One tray read after the run
309
+ * shows that: the card left the tray (read, or hidden by a defer) or its
310
+ * `your_last_decision` moved since the gate's tray. The host then
311
+ * records nothing more, so the agent's own last verdict stands and a
312
+ * reply is counted once. A failed read, or a card that may sit past a
313
+ * truncated tray, records `reply` as before (reading is forward-only). A turn
306
314
  * OpenClaw refuses, or one that ends in error or on the wait timeout,
307
315
  * records nothing: the conversation stays unread, the card stays on the
308
316
  * tray, and the ladder re-wakes so it is gated again (one more gate
@@ -494,6 +502,17 @@ declare class AgentInvoker {
494
502
  private admitted;
495
503
  /** The reply turn for `conversationId` is over: its card may be gated again, and a tray that held skipped cards is read once more. */
496
504
  private replyTurnEnded;
505
+ /**
506
+ * Whether the completed turn recorded a verdict for its conversation
507
+ * itself, seen on one fresh tray read. A card that left the tray was read
508
+ * (a verdict or a mark-read) or hidden by a `defer` — by the turn, since
509
+ * the host had recorded nothing for it. A card still there whose
510
+ * `your_last_decision` differs from the gate's copy got a verdict in the
511
+ * turn (a newer message keeps it on the tray). A card still there,
512
+ * unchanged, got nothing. A failed read, or a missing card past a
513
+ * truncated tray, claims nothing: `reply` is recorded as before.
514
+ */
515
+ private decidedInTurn;
497
516
  /** The `reply` verdict for a completed turn. A record the server refuses leaves the conversation unread; the ladder re-wakes. */
498
517
  private recordReply;
499
518
  /**
@@ -302,7 +302,15 @@ type TurnReadiness = {
302
302
  * start: recorded at admission it marked the conversation read before
303
303
  * the turn's own inbox call, which then waited on an empty tray, and a
304
304
  * turn that crashed left the peer with a read receipt and no answer. A
305
- * completed turn counts as read even if it chose not to send. A turn
305
+ * completed turn counts as read even if it chose not to send — unless
306
+ * the turn recorded a verdict for its conversation itself (the served
307
+ * texts tell the model to record `reply` after its send, or `dismiss`
308
+ * when it read and chose not to answer). One tray read after the run
309
+ * shows that: the card left the tray (read, or hidden by a defer) or its
310
+ * `your_last_decision` moved since the gate's tray. The host then
311
+ * records nothing more, so the agent's own last verdict stands and a
312
+ * reply is counted once. A failed read, or a card that may sit past a
313
+ * truncated tray, records `reply` as before (reading is forward-only). A turn
306
314
  * OpenClaw refuses, or one that ends in error or on the wait timeout,
307
315
  * records nothing: the conversation stays unread, the card stays on the
308
316
  * tray, and the ladder re-wakes so it is gated again (one more gate
@@ -494,6 +502,17 @@ declare class AgentInvoker {
494
502
  private admitted;
495
503
  /** The reply turn for `conversationId` is over: its card may be gated again, and a tray that held skipped cards is read once more. */
496
504
  private replyTurnEnded;
505
+ /**
506
+ * Whether the completed turn recorded a verdict for its conversation
507
+ * itself, seen on one fresh tray read. A card that left the tray was read
508
+ * (a verdict or a mark-read) or hidden by a `defer` — by the turn, since
509
+ * the host had recorded nothing for it. A card still there whose
510
+ * `your_last_decision` differs from the gate's copy got a verdict in the
511
+ * turn (a newer message keeps it on the tray). A card still there,
512
+ * unchanged, got nothing. A failed read, or a missing card past a
513
+ * truncated tray, claims nothing: `reply` is recorded as before.
514
+ */
515
+ private decidedInTurn;
497
516
  /** The `reply` verdict for a completed turn. A record the server refuses leaves the conversation unread; the ladder re-wakes. */
498
517
  private recordReply;
499
518
  /**
@@ -133,7 +133,7 @@ function applyAgentchatAccountPatch(cfg, accountId, patch) {
133
133
  }
134
134
 
135
135
  // src/version.ts
136
- var PACKAGE_VERSION = "0.9.1";
136
+ var PACKAGE_VERSION = "0.9.2";
137
137
 
138
138
  // src/client-identity.ts
139
139
  var AGENTCHAT_CLIENT_NAME = "openclaw";
@@ -429,7 +429,7 @@ function wakeTurnPrompt(texts, conversationId) {
429
429
  ${conversationLine(conversationId)}`;
430
430
  }
431
431
  function conversationLine(conversationId) {
432
- return `Conversation to answer in this turn: ${conversationId}. The gate decided reply; its card is still on the tray while you work, and the reply verdict for it is recorded for you when this turn completes (recording it yourself with ${DECIDE_TOOL} is idempotent) \u2014 open it with ${GET_CONVERSATION_TOOL} and reply.`;
432
+ return `Conversation to answer in this turn: ${conversationId}. The gate decided reply; its card is still on the tray while you work, and the reply verdict for it is recorded for you when this turn completes unless you record one yourself with ${DECIDE_TOOL} (reply after your answer is sent, or dismiss if you read and choose not to answer) \u2014 open it with ${GET_CONVERSATION_TOOL} and reply.`;
433
433
  }
434
434
  function inviteTurnPrompt(texts) {
435
435
  return texts.invite_prompt.trim();
@@ -2859,6 +2859,13 @@ var AgentInvoker = class {
2859
2859
  );
2860
2860
  return;
2861
2861
  }
2862
+ if (await this.decidedInTurn(reply)) {
2863
+ this.logger.info(
2864
+ { sessionKey, conversationId: reply.conversationId },
2865
+ "the turn recorded its own verdict \u2014 reply not recorded again"
2866
+ );
2867
+ return;
2868
+ }
2862
2869
  await this.recordReply(sessionKey, reply);
2863
2870
  } finally {
2864
2871
  this.replyTurnEnded(reply.conversationId);
@@ -2886,6 +2893,28 @@ var AgentInvoker = class {
2886
2893
  this.coalescer.wake();
2887
2894
  }
2888
2895
  }
2896
+ /**
2897
+ * Whether the completed turn recorded a verdict for its conversation
2898
+ * itself, seen on one fresh tray read. A card that left the tray was read
2899
+ * (a verdict or a mark-read) or hidden by a `defer` — by the turn, since
2900
+ * the host had recorded nothing for it. A card still there whose
2901
+ * `your_last_decision` differs from the gate's copy got a verdict in the
2902
+ * turn (a newer message keeps it on the tray). A card still there,
2903
+ * unchanged, got nothing. A failed read, or a missing card past a
2904
+ * truncated tray, claims nothing: `reply` is recorded as before.
2905
+ */
2906
+ async decidedInTurn(reply) {
2907
+ let tray;
2908
+ try {
2909
+ tray = await this.client.inbox.tray({ waitMs: 0, limit: POST_TURN_TRAY_LIMIT });
2910
+ } catch (err) {
2911
+ this.logger.info({ conversationId: reply.conversationId, err: describe4(err) }, "tray re-read after the turn failed \u2014 recording reply");
2912
+ return false;
2913
+ }
2914
+ const card = agentchatme.gate.cardsOf(tray).find((c) => c.conversation_id === reply.conversationId);
2915
+ if (!card) return tray.truncated !== true;
2916
+ return lastDecisionAt(card) !== lastDecisionAt(reply.card);
2917
+ }
2889
2918
  /** The `reply` verdict for a completed turn. A record the server refuses leaves the conversation unread; the ladder re-wakes. */
2890
2919
  async recordReply(sessionKey, reply) {
2891
2920
  try {
@@ -2951,6 +2980,11 @@ var AgentInvoker = class {
2951
2980
  }
2952
2981
  }
2953
2982
  };
2983
+ var POST_TURN_TRAY_LIMIT = 50;
2984
+ function lastDecisionAt(card) {
2985
+ const at = card.your_last_decision?.at;
2986
+ return typeof at === "string" && at.length > 0 ? at : null;
2987
+ }
2954
2988
  function describe4(err) {
2955
2989
  return err instanceof Error ? err.message : String(err);
2956
2990
  }