Files
OmniRoute/tests/unit/chat-log-array-tail-items-default.test.ts
Diego Rodrigues de Sa e Souza 9fb7d6a493 cherry-pick(pr-9735): feat(logging): bump CHAT_LOG_ARRAY_TAIL_ITEMS default 24 -> 128 (#9864)
* feat(logging): bump CHAT_LOG_ARRAY_TAIL_ITEMS default 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 tail-24 default
silently dropped the array's earlier entries behind an
_omniroute_truncated_array marker, so investigating why a specific tool
call (apply_patch) behaved oddly turned up nothing: its declared shape
(function vs custom type) was unrecoverable from the call log across 40
recent requests, even though the calls themselves succeeded.

Bumped the configurable default to comfortably cover real large tool
lists with headroom. Updated .env.example and docs/reference/
ENVIRONMENT.md to match (env-doc-sync check passes).

* 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.

---------

Co-authored-by: Markus Hartung <mail@hartmark.se>
2026-08-09 09:53:26 -03:00

28 lines
1.1 KiB
TypeScript

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