Skip to content

fix(logging): document CHAT_LOG_MAX_BODY_KB, capture messageCount for Responses API bodies - #10038

Merged
diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.50from
hartmark:feat/chat-log-truncation-config
Aug 13, 2026
Merged

diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.50from
hartmark:feat/chat-log-truncation-config

Conversation

@hartmark

Copy link
Copy Markdown
Contributor

Summary

Extracted from PR #9439 (agentic conversation tracking). This was originally cherry-picked from a larger "make chat-log truncation configurable" commit, but most of that scope (the CHAT_LOG_MAX_BODY_KB env var support itself, the estimateSizeFast() earlyExitAt parameterization) turned out to already be present on the current upstream/release/v3.8.50 tip — confirmed by running the relevant tests against pristine upstream before making any changes here. Only two genuine gaps remained, both fixed:

  1. Missing doc-sync entry. CHAT_LOG_MAX_BODY_KB was already read by getChatLogMaxBodyBytes() in code, but undocumented in .env.example and docs/reference/ENVIRONMENT.md. tests/unit/check-env-doc-sync.test.ts flags any env var read in code but missing from both doc files — documented it (both files required, the same test enforces the pairing).

  2. messageCount never computed for Responses API bodies. truncateForLog()'s summary only computed messageCount from obj.messages (the OpenAI-chat/Gemini field name) — a large /v1/responses request (which uses input[], not messages[]) got summarized with no count at all, leaving the dashboard's "Full Conversation" panel nothing to base its "N messages not shown" placeholder on for any Responses-API conversation, even though the same summarization logic applies to it.

⚠️ base-red inherited: #9985

Test plan

  • TDD: tests/unit/chatcore-log-truncation.test.ts's new regression test ("captures a message count for Responses API bodies too") — confirmed failing against the pre-fix code, passing after.
  • tests/unit/check-env-doc-sync.test.ts confirms CHAT_LOG_MAX_BODY_KB no longer appears in codeMissingEnv (the remaining drift in that test — ANTIGRAVITY_ALLOW_SIGNATURE_BYPASS, COMMANDCODE_API_URL, OMNIROUTE_STRICT_SYSTEM_PROVIDERS, TLS_FINGERPRINT_PROVIDERS — is pre-existing/unrelated, confirmed identical on a pristine upstream/release/v3.8.50 checkout).
  • tests/unit/chatcore-log-truncation.test.ts — 19/19 passing.
  • npx tsc --noEmit / npm run lint — clean.

@hartmark
hartmark requested a review from diegosouzapw as a code owner August 10, 2026 17:24
@hartmark
hartmark force-pushed the feat/chat-log-truncation-config branch 2 times, most recently from 18bbe97 to b20245d Compare August 12, 2026 17:21
@hartmark
hartmark force-pushed the feat/chat-log-truncation-config branch from b20245d to f80c51c Compare August 12, 2026 19:11
hartmark added a commit to hartmark/OmniRoute that referenced this pull request Aug 12, 2026
# Conflicts:
#	open-sse/handlers/chatCore/logTruncation.ts
#	tests/unit/chatcore-log-truncation.test.ts
… Responses API bodies

Extracted from PR diegosouzapw#9439 (agentic conversation tracking). Most of the
original scope this commit was cherry-picked from (CHAT_LOG_MAX_BODY_KB
env var support, the estimateSizeFast() earlyExitAt parameterization)
turned out to already be present on the current upstream/release/v3.8.50
tip -- confirmed via diff and by running check-env-doc-sync.test.ts /
tests/unit/chatcore-log-truncation.test.ts against pristine upstream
before making any changes here. Only two genuine gaps remained:

1. CHAT_LOG_MAX_BODY_KB was read by getChatLogMaxBodyBytes() but
   undocumented in .env.example and docs/reference/ENVIRONMENT.md --
   tests/unit/check-env-doc-sync.test.ts flags any env var read in code
   but missing from both doc files. Documented it (both required --
   the same test enforces the pairing).

2. truncateForLog()'s summary only computed messageCount from
   obj.messages (OpenAI-chat/Gemini field name) -- a large /v1/responses
   request (which uses input[], not messages[]) got summarized with no
   count at all, leaving the dashboard's "Full Conversation" panel
   nothing to base its "N messages not shown" placeholder on for any
   Responses-API conversation, even though the same summarization logic
   applies to it.

Test plan:
- TDD: tests/unit/chatcore-log-truncation.test.ts's new regression test
  ("captures a message count for Responses API bodies too") confirmed
  failing against the pre-fix code, passing after.
- tests/unit/check-env-doc-sync.test.ts confirms CHAT_LOG_MAX_BODY_KB no
  longer appears in codeMissingEnv (remaining drift in that test is
  pre-existing/unrelated -- ANTIGRAVITY_ALLOW_SIGNATURE_BYPASS,
  COMMANDCODE_API_URL, OMNIROUTE_STRICT_SYSTEM_PROVIDERS,
  TLS_FINGERPRINT_PROVIDERS -- confirmed identical on a pristine
  upstream/release/v3.8.50 checkout, base-red inherited: diegosouzapw#9985).
- tests/unit/chatcore-log-truncation.test.ts -- 19/19 passing.
- npx tsc --noEmit / npm run lint -- clean.

⚠️ base-red inherited: diegosouzapw#9985
@hartmark
hartmark force-pushed the feat/chat-log-truncation-config branch from f80c51c to 4f5e7a4 Compare August 12, 2026 19:24
hartmark added a commit to hartmark/OmniRoute that referenced this pull request Aug 12, 2026
# Conflicts:
#	open-sse/handlers/chatCore/logTruncation.ts
#	tests/unit/chatcore-log-truncation.test.ts
@diegosouzapw

Copy link
Copy Markdown
Owner

Verified: fix #2 (messageCount for /v1/responses input[] bodies) is real and TDD-proven — confirmed the pre-fix test fails and the post-fix test passes against a pristine base checkout. However, fix #1's premise doesn't hold: CHAT_LOG_MAX_BODY_KB was already documented in both .env.example (line ~2631, though with a stale comment pointing at a file that no longer exists, src/lib/chatLogTruncation.ts) and docs/reference/ENVIRONMENT.md (line ~1449, correctly referencing src/lib/logEnv.ts). Running check-env-doc-sync.mjs on the base tip confirms this var was never in the missing list. This PR adds a second, duplicate entry to each file rather than fixing the existing stale one — please consolidate into a single entry per file (and fix the stale file reference in .env.example) before merge. Not a functional blocker, just a documentation-accuracy nit worth a quick follow-up commit.


Note: the base-red that was failing this PR's CI (#9985) was drained today — base-reds PR #10213 just merged into release/v3.8.50. A rebase/sync onto the current tip should bring your checks green.

…er file

The variable was already documented (with a stale src/lib/chatLogTruncation.ts
reference in .env.example); keep the new richer entries next to the CHAT_LOG_*
family and drop the old duplicates.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw
diegosouzapw merged commit d925f6b into diegosouzapw:release/v3.8.50 Aug 13, 2026
15 of 16 checks passed
@diegosouzapw

Copy link
Copy Markdown
Owner

Merged — thanks @hartmark! messageCount now lands for Responses input[] bodies; we consolidated the duplicate CHAT_LOG_MAX_BODY_KB doc entries on your branch before merging (kept your richer copy next to the CHAT_LOG_* family).

muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
… Responses API bodies (diegosouzapw#10038)

* fix(logging): document CHAT_LOG_MAX_BODY_KB, capture messageCount for Responses API bodies

Extracted from PR diegosouzapw#9439 (agentic conversation tracking). Most of the
original scope this commit was cherry-picked from (CHAT_LOG_MAX_BODY_KB
env var support, the estimateSizeFast() earlyExitAt parameterization)
turned out to already be present on the current upstream/release/v3.8.50
tip -- confirmed via diff and by running check-env-doc-sync.test.ts /
tests/unit/chatcore-log-truncation.test.ts against pristine upstream
before making any changes here. Only two genuine gaps remained:

1. CHAT_LOG_MAX_BODY_KB was read by getChatLogMaxBodyBytes() but
   undocumented in .env.example and docs/reference/ENVIRONMENT.md --
   tests/unit/check-env-doc-sync.test.ts flags any env var read in code
   but missing from both doc files. Documented it (both required --
   the same test enforces the pairing).

2. truncateForLog()'s summary only computed messageCount from
   obj.messages (OpenAI-chat/Gemini field name) -- a large /v1/responses
   request (which uses input[], not messages[]) got summarized with no
   count at all, leaving the dashboard's "Full Conversation" panel
   nothing to base its "N messages not shown" placeholder on for any
   Responses-API conversation, even though the same summarization logic
   applies to it.

Test plan:
- TDD: tests/unit/chatcore-log-truncation.test.ts's new regression test
  ("captures a message count for Responses API bodies too") confirmed
  failing against the pre-fix code, passing after.
- tests/unit/check-env-doc-sync.test.ts confirms CHAT_LOG_MAX_BODY_KB no
  longer appears in codeMissingEnv (remaining drift in that test is
  pre-existing/unrelated -- ANTIGRAVITY_ALLOW_SIGNATURE_BYPASS,
  COMMANDCODE_API_URL, OMNIROUTE_STRICT_SYSTEM_PROVIDERS,
  TLS_FINGERPRINT_PROVIDERS -- confirmed identical on a pristine
  upstream/release/v3.8.50 checkout, base-red inherited: diegosouzapw#9985).
- tests/unit/chatcore-log-truncation.test.ts -- 19/19 passing.
- npx tsc --noEmit / npm run lint -- clean.

⚠️ base-red inherited: diegosouzapw#9985

* docs(logging): consolidate CHAT_LOG_MAX_BODY_KB into a single entry per file

The variable was already documented (with a stale src/lib/chatLogTruncation.ts
reference in .env.example); keep the new richer entries next to the CHAT_LOG_*
family and drop the old duplicates.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants