Skip to content

Commit 576a0ec

Browse files
Gkrumbach07claude
andcommitted
fix(backend): align DeriveAgentStatus tail buffer with scanner max line size
CodeRabbit correctly identified that DeriveAgentStatus was reading only 64KB from the file tail, which could truncate large events now that scannerMaxLineSize is 10MB. This would cause JSON parsing failures and return empty status. Changes: - Increase maxTailBytes from 64KB to 2x scannerMaxLineSize (20MB) - This ensures we can read at least one complete max-sized event plus additional events for proper status derivation - Keeps the value in sync with scannerMaxLineSize for future changes Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 10c85fe commit 576a0ec

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

components/backend/websocket/agui_store.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ func DeriveAgentStatus(sessionID string) string {
219219
path := fmt.Sprintf("%s/sessions/%s/agui-events.jsonl", StateBaseDir, sessionID)
220220

221221
// Read only the tail of the file to avoid loading entire event log into memory.
222-
// 64KB is sufficient for recent lifecycle events (scanning backwards).
223-
const maxTailBytes = 64 * 1024
222+
// Use 2x scannerMaxLineSize to ensure we can read at least one complete max-sized
223+
// event line plus additional events for proper status derivation.
224+
maxTailBytes := int64(scannerMaxLineSize * 2)
224225

225226
file, err := os.Open(path)
226227
if err != nil {

0 commit comments

Comments
 (0)