openzoo 0.48.33 → 0.48.34

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/lib/proxy.js +22 -0
  2. package/package.json +1 -1
package/lib/proxy.js CHANGED
@@ -339,6 +339,28 @@ async function spillTranscript(body, log) {
339
339
  }
340
340
  if (cut <= firstSpillable) return null; // nothing safely severable
341
341
 
342
+ // TRIM THE TAIL BY BYTES, NOT MESSAGE COUNT.
343
+ //
344
+ // MEASURED on the live session: 9 kept turns of Claude Code tool output made
345
+ // promptTokens swamp the counterfactual and the call scored 1.00x, while the
346
+ // SAME bound context with a one-line ask scored 8.53x. Nine messages is a
347
+ // trivial number and an enormous payload — a single Read or grep result is
348
+ // tens of KB — so counting messages measures the wrong thing entirely.
349
+ //
350
+ // Walk backwards from the newest and stop at a byte budget. The newest turns
351
+ // are the ones the model actually needs verbatim; everything older is already
352
+ // in the bound corpus and comes back through recall.
353
+ let tailStart = cut;
354
+ {
355
+ const budget = Number(process.env.OPENZOO_TAIL_MAX_CHARS || 24000);
356
+ let used = 0;
357
+ for (let i = msgs.length - 1; i >= cut; i--) {
358
+ used += msgText(msgs[i]).length;
359
+ if (used > budget && severable(i)) { tailStart = i; break; }
360
+ }
361
+ }
362
+ if (tailStart > cut) cut = tailStart;
363
+
342
364
  const head = msgs.slice(0, firstSpillable); // system block, always kept
343
365
  const corpus = msgs.slice(firstSpillable, cut).map(msgText).filter(Boolean).join('\n\n');
344
366
  if (corpus.length <= BIND_MIN_CHARS) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openzoo",
3
- "version": "0.48.33",
3
+ "version": "0.48.34",
4
4
  "description": "Local x402-paying proxy + MCP server for openzoo.fun — point any OpenAI-compatible harness (Cursor, Claude Code, aider, SDKs) at localhost and it pays per call from a local burner wallet. Solana and Base rails live; Robinhood experimental.",
5
5
  "license": "MIT",
6
6
  "type": "module",