@warpmetrics/warp 0.0.12 → 0.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warpmetrics/warp",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Measure your agents, not your LLM calls.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -139,13 +139,20 @@ export async function flush() {
139
139
  if (config.debug) {
140
140
  console.error('[warpmetrics] Flush failed:', err.message);
141
141
  }
142
- // Re-queue so nothing is lost.
143
- queue.runs.unshift(...batch.runs);
144
- queue.groups.unshift(...batch.groups);
145
- queue.calls.unshift(...batch.calls);
146
- queue.links.unshift(...batch.links);
147
- queue.outcomes.unshift(...batch.outcomes);
148
- queue.acts.unshift(...batch.acts);
142
+ // Only re-queue if it's not a rate limit error (429)
143
+ // Rate limit errors should wait for the next flush interval
144
+ const isRateLimit = err.message?.includes('429') || err.message?.includes('RATE_LIMIT');
145
+ if (!isRateLimit) {
146
+ // Re-queue so nothing is lost.
147
+ queue.runs.unshift(...batch.runs);
148
+ queue.groups.unshift(...batch.groups);
149
+ queue.calls.unshift(...batch.calls);
150
+ queue.links.unshift(...batch.links);
151
+ queue.outcomes.unshift(...batch.outcomes);
152
+ queue.acts.unshift(...batch.acts);
153
+ } else if (config.debug) {
154
+ console.warn('[warpmetrics] Rate limited - discarding batch to avoid retry loop. Will retry on next flush.');
155
+ }
149
156
  }
150
157
  }
151
158
 
package/src/trace/call.js CHANGED
@@ -24,7 +24,10 @@ export function call(target, response, opts) {
24
24
  return;
25
25
  }
26
26
 
27
- const entry = responseRegistry.get(response);
27
+ // Auto-extract _warpResponse if present (error case)
28
+ const actualResponse = response?._warpResponse || response;
29
+
30
+ const entry = responseRegistry.get(actualResponse);
28
31
  if (!entry) {
29
32
  if (getConfig().debug) console.warn('[warpmetrics] call() — response not tracked. Was it from a warp()-ed client?');
30
33
  return;
@@ -37,5 +40,5 @@ export function call(target, response, opts) {
37
40
  logLink({ parentId: targetId, childId: id, type: 'call' });
38
41
  parentData.calls.push(id);
39
42
 
40
- responseRegistry.delete(response);
43
+ responseRegistry.delete(actualResponse);
41
44
  }