billion-context 0.1.53-pr.239.86 → 0.1.53-pr.244.85

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/dist/index.js CHANGED
@@ -50295,7 +50295,6 @@ async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adap
50295
50295
  const calls = [];
50296
50296
  let usage = {};
50297
50297
  let finishReason;
50298
- let sawDone = false;
50299
50298
  let suppressCompletion = false;
50300
50299
  for await (const ev of adapter.parseStream(currentUpstream, round)) {
50301
50300
  if (signal?.aborted) break;
@@ -50333,7 +50332,6 @@ async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adap
50333
50332
  cachedTokens: ev.cachedTokens
50334
50333
  };
50335
50334
  } else if (ev.kind === "done") {
50336
- sawDone = true;
50337
50335
  finishReason = ev.finishReason;
50338
50336
  suppressCompletion = ev.suppressCompletion === true;
50339
50337
  } else if (ev.kind === "meta") {
@@ -50455,15 +50453,6 @@ async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adap
50455
50453
  }
50456
50454
  const reRequest = proxyResults.length > 0 && realCalls === 0;
50457
50455
  if (!reRequest) {
50458
- if (!sawDone) {
50459
- const partialText = assistantText.length;
50460
- const partialReasoning = assistantReasoning.length;
50461
- const msg = `upstream stream truncated (no completion event; round ${round}, ${partialText} text chars + ${partialReasoning} reasoning chars received)`;
50462
- ctx.log(`[acp-loop] round ${round}: ${msg}`);
50463
- log("error", `[acp-loop] ${msg}`);
50464
- yield adapter.emitError(msg);
50465
- return;
50466
- }
50467
50456
  if (!suppressCompletion) {
50468
50457
  yield adapter.emitCompletion({ finishReason, usage });
50469
50458
  }
@@ -50546,6 +50535,24 @@ async function* runCompressLoop(upstream, ctx, requestBody, requestOptions, adap
50546
50535
  }
50547
50536
 
50548
50537
  // src/loop/adapter-responses.ts
50538
+ function shortItemHash(input) {
50539
+ let h = 2166136261;
50540
+ for (let i = 0; i < input.length; i++) {
50541
+ h ^= input.charCodeAt(i);
50542
+ h = Math.imul(h, 16777619);
50543
+ }
50544
+ return (h >>> 0).toString(36);
50545
+ }
50546
+ var RESPONSES_ITEM_ID_MAX = 64;
50547
+ function sanitizeResponsesInputIds(input) {
50548
+ if (!Array.isArray(input)) return;
50549
+ for (const item of input) {
50550
+ const rec = item;
50551
+ if (typeof rec?.id === "string" && rec.id.length > RESPONSES_ITEM_ID_MAX) {
50552
+ rec.id = `msg-fix-${shortItemHash(rec.id)}`;
50553
+ }
50554
+ }
50555
+ }
50549
50556
  function rewriteItemEvent(type, obj, mapped) {
50550
50557
  const item = { ...obj.item ?? {}, id: mapped.id };
50551
50558
  return Buffer.from(`event: ${type}
@@ -50777,7 +50784,7 @@ function createResponsesAdapter(textProtocol, projection) {
50777
50784
  yield { kind: "meta", chunk: rawBuf, firstRoundOnly: false };
50778
50785
  } else if (item?.type === "message" && round > 1 && !suppressTextLifecycle) {
50779
50786
  const origId = typeof item.id === "string" ? item.id : "";
50780
- const mapped = { id: `msg-proxy-${round}-${origId || outputIndex}`, index: outputIndex++ };
50787
+ const mapped = { id: `msg-proxy-${round}-${shortItemHash(origId || String(outputIndex))}`, index: outputIndex++ };
50781
50788
  if (origId) remapped.set(origId, mapped);
50782
50789
  yield { kind: "meta", chunk: rewriteItemEvent(type, obj, mapped), firstRoundOnly: false };
50783
50790
  } else if (item?.type !== "message" || !suppressTextLifecycle) {
@@ -54709,6 +54716,7 @@ function prepareResponses(parsed, req, opts, core, config, prompts, log2, sessio
54709
54716
  let responsesProjection;
54710
54717
  let rebuiltInput = parsed.input;
54711
54718
  let toolsOut = parsed.tools;
54719
+ sanitizeResponsesInputIds(parsed.input);
54712
54720
  const shouldInject = opts.compress.injectTool;
54713
54721
  const injectTools = shouldInject && !pluginMode;
54714
54722
  const responsesTextProtocol = FORCE_TEXT_PROTOCOL || resolveCompressProtocol(opts.routes, session.meta.upstreamOrigin) === "marker";