Skip to content

Remove per-chunk UpdateMessage debug log#1896

Merged
trungutt merged 1 commit intodocker:mainfrom
trungutt:fix/remove-update-message-debug-log
Mar 3, 2026
Merged

Remove per-chunk UpdateMessage debug log#1896
trungutt merged 1 commit intodocker:mainfrom
trungutt:fix/remove-update-message-debug-log

Conversation

@trungutt
Copy link
Contributor

@trungutt trungutt commented Mar 3, 2026

Problem

During LLM streaming, persistStreamingContent is called on every chunk received from the model. Each call invokes SQLiteSessionStore.UpdateMessage, which contained a slog.Debug that fired once per chunk.

For a single short response (~1500 characters, ~5 seconds of streaming), this produced 123 identical log lines:

level=DEBUG msg="[STORE] UpdateMessage" message_id=9450 role=assistant agent=root
level=DEBUG msg="[STORE] UpdateMessage" message_id=9450 role=assistant agent=root
level=DEBUG msg="[STORE] UpdateMessage" message_id=9450 role=assistant agent=root
... (120 more)

The same message_id, role, and agent on every line — no new information per call. This single pattern accounted for ~30% of all log output in cagent.debug.log in some specific situation. 30% might be optimistic.

Fix

This PR suggests removing the slog.Debug call from SQLiteSessionStore.UpdateMessage.

The first message creation is already logged once in persistStreamingContent via [PERSIST] Created streaming message, which captures the message_id for correlation. Errors in UpdateMessage (sync failures, ErrNotFound) are still surfaced via slog.Warn — so we can have enough info for a diagnostic if needed

During streaming, persistStreamingContent is called on every chunk
received from the LLM, which in turn calls UpdateMessage on every
chunk. The debug log in UpdateMessage fired once per chunk, producing
~120 identical log lines for a single short response (~1500 chars).

The log carried no new information per call (same message_id, role,
and agent on every line) and dominated the debug log file.

The first message creation is already logged in persistStreamingContent
via '[PERSIST] Created streaming message', which provides the message_id
for correlation. The UpdateMessage path needs no additional log.
@trungutt trungutt requested a review from a team as a code owner March 3, 2026 10:11
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

✅ This PR looks good! The removal of the per-chunk debug log is a straightforward observability improvement.

What was verified:

  • The debug log was firing 123+ times for a single streaming response
  • Message creation is already logged once in persistStreamingContent
  • Error handling remains intact through existing slog.Warn calls
  • No functional impact — purely reduces log noise

This change improves log readability without losing diagnostic capability.

@trungutt trungutt merged commit 21ff9b7 into docker:main Mar 3, 2026
8 checks passed
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