Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1.5 KB
Raw Blame
/**
 * Regression test for the CHAT_LOG_ARRAY_TAIL_ITEMS default bumps: 24 -> 128 -> 1000.
 *
 * Real agentic CLIs with many MCP servers routinely declare 40-50+ tools in
 * a single request — a live OpenClaw session logged 47 — and a multi-round
 * tool-calling turn logs well over a hundred input items. Worse than a
 * diagnosability gap: `resolvePreviousResponseState`
 * (responsesContinuationStore.ts) reads this same bounded artifact back to
 * reconstruct `previous_response_id` history server-side, so once a stored
 * conversation's input/output array crossed the cap, continuation failed
 * the call outright on the `_omniroute_truncated_array` sentinel. Retention
 * (CALL_LOG_RETENTION_DAYS) already bounds total on-disk size independent of
 * this per-item cap, so raising it further doesn't change the storage
 * ceiling.
 *
 * Pins the literal default so a future edit can't silently regress it back
 * toward one of the old, too-small values.
 */
import { test } from "node:test";
import assert from "node:assert/strict";
import { getChatLogArrayTailItems } from "@/lib/logEnv";

test("getChatLogArrayTailItems defaults to 1000 (not the old 24 or 128) when unset", () => {
  const saved = process.env.CHAT_LOG_ARRAY_TAIL_ITEMS;
  delete process.env.CHAT_LOG_ARRAY_TAIL_ITEMS;
  try {
    assert.equal(getChatLogArrayTailItems(), 1000);
  } finally {
    if (saved === undefined) delete process.env.CHAT_LOG_ARRAY_TAIL_ITEMS;
    else process.env.CHAT_LOG_ARRAY_TAIL_ITEMS = saved;
  }
});