Files
OmniRoute/tests/unit/chat-log-array-tail-items-default.test.ts
Markus Hartung 3f6a881b6c fix(logging): raise chat-log array truncation cap to 1000 and unify duplicate implementations (#11499)
Validated in a combined 2-PR batch worktree off release/v3.8.51 tip (companion fix to #11473, merged first).
- Focused tests: chat-log-array-tail-items-default, chatcore-log-truncation, request-logger-bounded-clone, request-logger-bounded-idempotence, repro-7847-bound-client-raw-request — part of batch's 46/46 node:test run
- typecheck:core, file-size, changelog-integrity, complexity, cognitive-complexity — all OK
- Full-repo lint: 228 pre-existing dashboard react-hooks/* findings, unrelated to this diff

Thanks for unifying the two independently-drifted truncation caps onto one configurable source — measured evidence that the storage ceiling comes from retention days, not the per-item cap, makes the 128→1000 raise a clear correctness improvement.
2026-08-25 20:11:56 -03:00

33 lines
1.5 KiB
TypeScript

/**
* 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;
}
});