Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions components/backend/websocket/agui_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ var StateBaseDir string

const (
// Scanner buffer sizes for reading JSONL files
scannerInitialBufferSize = 64 * 1024 // 64KB initial buffer
scannerMaxLineSize = 1024 * 1024 // 1MB max line size
scannerInitialBufferSize = 64 * 1024 // 64KB initial buffer
scannerMaxLineSize = 10 * 1024 * 1024 // 10MB max line size (increased from 1MB to support large MCP tool results)
)

// ─── Live event pipe (multi-client broadcast) ───────────────────────
Expand Down Expand Up @@ -219,8 +219,9 @@ func DeriveAgentStatus(sessionID string) string {
path := fmt.Sprintf("%s/sessions/%s/agui-events.jsonl", StateBaseDir, sessionID)

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

file, err := os.Open(path)
if err != nil {
Expand Down
Loading