@vectorize-io/hindsight-coding-agents 0.3.1 → 0.3.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.
@@ -16073,10 +16073,10 @@ async function supportsAppend(client) {
16073
16073
  return false;
16074
16074
  }
16075
16075
  }
16076
+ var DEFAULT_RETRY_WINDOW_MS = 6e4;
16076
16077
  var RETAIN_RETRY_ATTEMPTS = 2;
16077
- var RETAIN_RETRY_BUDGET_MS = 6e3;
16078
- async function submitWithRetry(send, isStillNewest) {
16079
- let spent = 0;
16078
+ var REQUEST_BUDGET_MS = 15e3;
16079
+ async function submitWithRetry(send, isStillNewest, retryUntil) {
16080
16080
  for (let attempt = 0; ; attempt++) {
16081
16081
  try {
16082
16082
  return await send();
@@ -16084,8 +16084,7 @@ async function submitWithRetry(send, isStillNewest) {
16084
16084
  const limited = e instanceof RateLimitedError;
16085
16085
  if (!limited || attempt >= RETAIN_RETRY_ATTEMPTS || !isStillNewest()) throw e;
16086
16086
  const wait = e.retryAfterMs || 1e3;
16087
- if (wait > RETAIN_RETRY_BUDGET_MS - spent) throw e;
16088
- spent += wait;
16087
+ if (Date.now() + wait + REQUEST_BUDGET_MS > retryUntil) throw e;
16089
16088
  await sleep(wait);
16090
16089
  }
16091
16090
  }
@@ -16105,14 +16104,24 @@ function serialize(cursors, sessionId, write2) {
16105
16104
  }
16106
16105
  async function retainLiveSession(client, sessionId, turns, startTs, harness, opts = {}) {
16107
16106
  const cursors = opts.cursors;
16108
- if (!cursors) return writeSession(client, sessionId, turns, startTs, harness, opts.stamp);
16107
+ if (!cursors)
16108
+ return writeSession(
16109
+ client,
16110
+ sessionId,
16111
+ turns,
16112
+ startTs,
16113
+ harness,
16114
+ opts.stamp,
16115
+ void 0,
16116
+ opts.retryUntil
16117
+ );
16109
16118
  return serialize(
16110
16119
  cursors,
16111
16120
  sessionId,
16112
- () => writeSession(client, sessionId, turns, startTs, harness, opts.stamp, cursors)
16121
+ () => writeSession(client, sessionId, turns, startTs, harness, opts.stamp, cursors, opts.retryUntil)
16113
16122
  );
16114
16123
  }
16115
- async function writeSession(client, sessionId, turns, startTs, harness, stamp, cursors) {
16124
+ async function writeSession(client, sessionId, turns, startTs, harness, stamp, cursors, retryUntil = Date.now() + DEFAULT_RETRY_WINDOW_MS) {
16116
16125
  const refId = `conversation:${sessionId}`;
16117
16126
  const appendSupported = Boolean(cursors) && await supportsAppend(client);
16118
16127
  const plan = planRetain(turns, cursors?.read(sessionId), { appendSupported, bank: client.bank });
@@ -16164,7 +16173,8 @@ ${content}`),
16164
16173
  if (!cursors) return true;
16165
16174
  const now = cursors.read(sessionId);
16166
16175
  return now?.turns === claimed.turns && now?.fingerprint === claimed.fingerprint;
16167
- }
16176
+ },
16177
+ retryUntil
16168
16178
  );
16169
16179
  cursors?.write(sessionId, next);
16170
16180
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectorize-io/hindsight-coding-agents",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/vectorize-io/hindsight.git",