Skip to content

Commit 1af6d3a

Browse files
Gkrumbach07claude
andauthored
fix(backend): increase AG-UI event buffer size from 1MB to 10MB (#964)
## Summary - Increase scannerMaxLineSize from 1MB to 10MB in agui_store.go to support large MCP tool results - Fixes "Failed to decode JSON: JSON message exceeded maximum buffer size of 1048576 bytes" error ## Problem When MCP tools (like Jira) return large datasets, the JSON-serialized tool result can exceed the 1MB scanner buffer limit. This causes: - Events failing to persist to the JSONL event log - Session export failures - Event replay failures on reconnection ## Solution Increased the buffer size from 1MB to 10MB: - Scanner still starts with 64KB and only grows as needed (no memory waste for small events) - 10MB is reasonable for large MCP tool results (Jira boards, database queries, etc.) - Matches common HTTP body size limits ## Changes - `components/backend/websocket/agui_store.go`: Increase `scannerMaxLineSize` from `1024 * 1024` (1MB) to `10 * 1024 * 1024` (10MB) ## Test plan - [x] Run websocket tests: `go test ./websocket/... -v` - all pass - [x] Run go vet: `go vet ./websocket/...` - no issues - [x] Run golangci-lint: `golangci-lint run ./websocket/...` - 0 issues - [x] Verify gofmt: `gofmt -l websocket/` - no formatting issues - [ ] Manual test: Fetch large Jira board via MCP and verify events persist correctly 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 9d9d9b7 commit 1af6d3a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

components/backend/websocket/agui_store.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ var StateBaseDir string
5757

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

6464
// ─── Live event pipe (multi-client broadcast) ───────────────────────
@@ -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)