Repository navigation
fix(logging): raise chat-log array truncation cap to 1000 and unify duplicate implementations - #11499
Merged
diegosouzapw merged 1 commit intoAug 25, 2026
Conversation
…uplicate implementations CHAT_LOG_ARRAY_TAIL_ITEMS default 128 -> 1000: a multi-round agentic tool-calling turn routinely logs well over a hundred input items, and resolvePreviousResponseState reads this same bounded artifact back to reconstruct previous_response_id history server-side -- once a stored conversation's input/output array crossed the cap, continuation failed outright on the truncation sentinel, not just a diagnosability gap. Retention (CALL_LOG_RETENTION_DAYS) already bounds total on-disk size independent of this per-item cap. requestLogger.ts's cloneBoundedForLog had its own separate hardcoded MAX_LOG_ARRAY_ITEMS = 24, independent of and drifting from chatCore/logTruncation.ts's cloneBoundedChatLogPayload, which already read the configurable getChatLogArrayTailItems(). Pointed both at the same value so the two bounding passes over the same artifact data stay consistent.
diegosouzapw
merged commit Aug 25, 2026
3f6a881
into
cheaper-inference:release/v3.8.51
7 of 16 checks passed
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…uplicate implementations (cheaper-inference#11499) Validated in a combined 2-PR batch worktree off release/v3.8.51 tip (companion fix to cheaper-inference#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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
resolvePreviousResponseState(added forprevious_response_idserver-sidecontinuation) reads the same call-log artifact that
cloneBoundedChatLogPayloadand
cloneBoundedForLogbound for storage. Once a stored conversation'sinput/outputarray crossed the truncation cap, continuation hit the_omniroute_truncated_arraysentinel and the reconstructed request becameunresolvable — worse than a diagnosability gap, it broke the call outright
(see the companion fix in #11473).
Separately,
open-sse/utils/requestLogger.ts'scloneBoundedForLoghad itsown independent hardcoded
MAX_LOG_ARRAY_ITEMS = 24, drifted from andduplicating
open-sse/handlers/chatCore/logTruncation.ts'scloneBoundedChatLogPayload, which already read the configurablegetChatLogArrayTailItems()(previously defaulted to 128).Why This Change Was Made
input items (reasoning/function_call/function_call_output triples per
round), so even the existing 128 default was tight for real usage.
CALL_LOG_RETENTION_DAYS(default 7 days) already bounds total on-diskstorage independent of this per-item cap — raising the cap doesn't change
the storage ceiling, it only changes how much of a single long conversation
stays reconstructable within the retention window. Measured ~2.1GB for 7
days of call-log artifacts on a live instance; the per-item cap was never
the actual storage constraint.
getChatLogArrayTailItems()(env-configurable viaCHAT_LOG_ARRAY_TAIL_ITEMS) so the two bounding passes over the sameartifact data can't drift again.
User Impact
previous_response_idcontinuation stays resolvable for much longerreal-world conversations before falling back to full history.
threshold, which is a debug/reconstruction fidelity concern, not a size
control (size is controlled by retention days/row count).
CHAT_LOG_ARRAY_TAIL_ITEMSif 1000 istoo high or too low for their traffic pattern.
Evidence
resolvePreviousResponseStatereturned avalid reconstruction when called directly against on-disk data, but the
live dev server (
omniroute-dev, running 14+ hours through many liveHMR edits) returned a stale null for the identical lookup — traced this
to that dev instance being stale, not a code bug (fixed by restart,
unrelated to this PR).
node --import tsx --test tests/unit/chat-log-array-tail-items-default.test.ts tests/unit/chatcore-log-truncation.test.ts tests/unit/request-logger-bounded-clone.test.ts tests/unit/request-logger-bounded-idempotence.test.ts tests/unit/repro-7847-bound-client-raw-request.test.ts tests/unit/responses-continuation-store.test.ts), including three testfiles updated to exercise truncation above the new 1000-item cap instead
of the old 24/128-item fixtures.
two-call continuation test (
previous_response_idset on call 2) logged1 msgsand returned 200 for both calls.