fix(logging): document CHAT_LOG_MAX_BODY_KB, capture messageCount for Responses API bodies - #10038
Conversation
18bbe97 to
b20245d
Compare
b20245d to
f80c51c
Compare
# 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
f80c51c to
4f5e7a4
Compare
# Conflicts: # open-sse/handlers/chatCore/logTruncation.ts # tests/unit/chatcore-log-truncation.test.ts
|
Verified: fix #2 (messageCount for /v1/responses Note: the base-red that was failing this PR's CI (#9985) was drained today — base-reds PR #10213 just merged into |
…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>
d925f6b
into
diegosouzapw:release/v3.8.50
|
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). |
… 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>
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_KBenv var support itself, theestimateSizeFast()earlyExitAtparameterization) turned out to already be present on the currentupstream/release/v3.8.50tip — confirmed by running the relevant tests against pristine upstream before making any changes here. Only two genuine gaps remained, both fixed:Missing doc-sync entry.
CHAT_LOG_MAX_BODY_KBwas already read bygetChatLogMaxBodyBytes()in code, but undocumented in.env.exampleanddocs/reference/ENVIRONMENT.md.tests/unit/check-env-doc-sync.test.tsflags any env var read in code but missing from both doc files — documented it (both files required, the same test enforces the pairing).messageCountnever computed for Responses API bodies.truncateForLog()'s summary only computedmessageCountfromobj.messages(the OpenAI-chat/Gemini field name) — a large/v1/responsesrequest (which usesinput[], notmessages[]) 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
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.tsconfirmsCHAT_LOG_MAX_BODY_KBno longer appears incodeMissingEnv(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 pristineupstream/release/v3.8.50checkout).tests/unit/chatcore-log-truncation.test.ts— 19/19 passing.npx tsc --noEmit/npm run lint— clean.