fix(backend): increase AG-UI event buffer size from 1MB to 10MB#964
fix(backend): increase AG-UI event buffer size from 1MB to 10MB#964Gkrumbach07 merged 2 commits intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe JSONL scanner max line size in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@components/backend/websocket/agui_store.go`:
- Around line 60-61: DeriveAgentStatus currently reads only maxTailBytes (64KB)
from the file tail which can truncate final JSONL lines now that
scannerMaxLineSize is 10MB; change the logic in DeriveAgentStatus to set
maxTailBytes to at least scannerMaxLineSize (or a bounded multiple, e.g.,
min(fileSize, scannerMaxLineSize * 2)) so the scanner buffer can contain an
entire max-sized line before parsing; update any related variables (maxTailBytes
usage and scannerInitialBufferSize consideration) to ensure bufio.Scanner is
configured with scannerMaxLineSize and will not drop/trim the final line when
parsing status.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 629e282d-d6ef-427d-8146-580f782885f5
📒 Files selected for processing (1)
components/backend/websocket/agui_store.go
PR Review SummaryI've checked the CI status and reviewed the code changes. Here's what I found: ✅ Passing Checks
❌ E2E Test Failure (Unrelated to this PR)The E2E test failure is not caused by this change:
📝 Code ReviewChange: Increase Security: ✓ No concerns
Error Handling: ✓ Appropriate
Memory Safety: ✓ Safe
Testing: ✓ Comprehensive
Logic: ✓ Correct
🎯 RecommendationThis PR is ready to merge. The E2E test failure is a transient infrastructure issue unrelated to this change. All relevant tests for the modified code pass, and the change is safe, well-tested, and solves the reported issue. |
CodeRabbit Review - AddressedIssue: CodeRabbit flagged that Fix: Commit 576a0ec - Increased This ensures:
The review thread has been resolved. Thanks @coderabbitai for catching this edge case! |
|
Tip For best results, initiate chat on the files or code changes.
|
576a0ec to
48d2d28
Compare
✅ Rebased onto latest mainSuccessfully rebased branch onto
Commits after rebase:
PR is ready for review and merge. |
When MCP tools return large data (e.g., Jira board lists with many issues), the JSON-serialized tool result can exceed the 1MB scanner buffer limit. This causes errors like "Failed to decode JSON: JSON message exceeded maximum buffer size of 1048576 bytes" and prevents events from being persisted and replayed. Changes: - Increase scannerMaxLineSize from 1MB to 10MB in agui_store.go - Affects both event persistence (loadEvents) and session export - Scanner still starts with 64KB buffer and only grows as needed - 10MB is a reasonable limit for large MCP tool results Fixes: #<issue-number> Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ne 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>
48d2d28 to
bb60b5d
Compare
Final Pre-Merge Review ✅Diff Audit
CI Status (all green)
Local Checks
Review Items Addressed
This PR is clean and ready to merge. |
Summary
Problem
When MCP tools (like Jira) return large datasets, the JSON-serialized tool result can exceed the 1MB scanner buffer limit. This causes:
Solution
Increased the buffer size from 1MB to 10MB:
Changes
components/backend/websocket/agui_store.go: IncreasescannerMaxLineSizefrom1024 * 1024(1MB) to10 * 1024 * 1024(10MB)Test plan
go test ./websocket/... -v- all passgo vet ./websocket/...- no issuesgolangci-lint run ./websocket/...- 0 issuesgofmt -l websocket/- no formatting issues🤖 Generated with Claude Code