From 4a9593d740e81e39a2ea1eb2d4283c7381c3ab82 Mon Sep 17 00:00:00 2001 From: Markus Hartung Date: Fri, 7 Aug 2026 23:29:48 +0200 Subject: [PATCH] test(logging): pin CHAT_LOG_ARRAY_TAIL_ITEMS default at 128 The bump commit had no dedicated test asserting the literal default value; the existing chatcore-log-truncation.test.ts derives its expectations from getChatLogArrayTailItems() itself, so it can't discriminate a regression back toward the old, too-small 24 default. --- .../chat-log-array-tail-items-default.test.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/unit/chat-log-array-tail-items-default.test.ts diff --git a/tests/unit/chat-log-array-tail-items-default.test.ts b/tests/unit/chat-log-array-tail-items-default.test.ts new file mode 100644 index 0000000000..fa2bc4fb1f --- /dev/null +++ b/tests/unit/chat-log-array-tail-items-default.test.ts @@ -0,0 +1,27 @@ +/** + * Regression test for the CHAT_LOG_ARRAY_TAIL_ITEMS default bump 24 -> 128. + * + * Real agentic CLIs with many MCP servers routinely declare 40-50+ tools in + * a single request — a live OpenClaw session logged 47. The old tail-24 + * default silently dropped the array's earlier entries behind an + * `_omniroute_truncated_array` marker, including (in one traced case) the + * tool actually being called, making its declared shape unrecoverable from + * the call log even though the call itself succeeded. + * + * Pins the literal default so a future edit can't silently regress it back + * toward the old, too-small value. + */ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { getChatLogArrayTailItems } from "@/lib/logEnv"; + +test("getChatLogArrayTailItems defaults to 128 (not the old 24) when unset", () => { + const saved = process.env.CHAT_LOG_ARRAY_TAIL_ITEMS; + delete process.env.CHAT_LOG_ARRAY_TAIL_ITEMS; + try { + assert.equal(getChatLogArrayTailItems(), 128); + } finally { + if (saved === undefined) delete process.env.CHAT_LOG_ARRAY_TAIL_ITEMS; + else process.env.CHAT_LOG_ARRAY_TAIL_ITEMS = saved; + } +});