Skip to content

fix(sidecars): bound streamed response bytes - #1376

Merged
Wibias merged 1 commit into
lidge-jun:devfrom
luvs01:agent/bound-sidecar-sse
Aug 10, 2026
Merged

fix(sidecars): bound streamed response bytes#1376
Wibias merged 1 commit into
lidge-jun:devfrom
luvs01:agent/bound-sidecar-sse

Conversation

@luvs01

@luvs01 luvs01 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Bound raw Responses SSE consumed by web-search and vision sidecars to 64 KiB before decoded and authoritative/delta copies can accumulate.
  • Preserve complete events accepted up to the cap, keep current data: parsing and malformed-frame behavior, and cancel upstream without letting a rejecting or stalled cancel fail the partial result.
  • Add exact-boundary, no-space data, partial-event, truncated UTF-8, and cancellation-rejection regressions.
  • Keep the Sources-header linear-scan stress cases substantial while fitting below the new transport ceiling.

Verification

  • Bun 1.3.14: bun test tests/web-search-parse.test.ts — 36 passed.
  • bun run typecheck — passed.
  • bun run privacy:scan — passed.
  • git diff --check HEAD^ HEAD — passed.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Comments for both sidecar callers document the shared response ceiling.
  • The branch is based on the latest dev.

Review readiness checklist

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes

    • Limited streamed search and vision responses to 64 KiB to prevent excessively large responses.
    • Preserved complete events and partial output when responses are truncated.
    • Improved handling of cancelled or interrupted streams, including malformed UTF-8 data.
  • Tests

    • Added coverage for response limits, cancellation behavior, partial events, and truncated data.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 9, 2026
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently. If no CodeRabbit review appears, comment @coderabbitai review to request one.
Maintainers: @lidge-jun @Ingwannu @Wibias

Wibias commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Please rebase this PR onto the latest dev (e8ce2b93dd3ef8074d96dee407704c5dc06e2699) before merge, then rerun the exact-head CI checks.

@luvs01
luvs01 force-pushed the agent/bound-sidecar-sse branch from 1ba46c8 to 30adf56 Compare August 9, 2026 23:25
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2eb93497-fcb6-413e-807e-5e8d9ad87263

📥 Commits

Reviewing files that changed from the base of the PR and between d517161 and 30adf56.

📒 Files selected for processing (4)
  • src/vision/describe.ts
  • src/web-search/executor.ts
  • src/web-search/parse.ts
  • tests/web-search-parse.test.ts

📝 Walkthrough

Walkthrough

The sidecar SSE parser now limits streamed input to 64 KiB, processes complete accepted events, discards truncated data, and cancels the reader without waiting. Tests cover byte boundaries, UTF-8 truncation, cancellation failures, and header parsing. Comments document the limit.

Changes

Sidecar SSE response limits

Layer / File(s) Summary
Bounded parser and cancellation
src/web-search/parse.ts:32-35, src/web-search/parse.ts:182-190, src/web-search/parse.ts:204, src/web-search/parse.ts:259-275, src/vision/describe.ts:83-84, src/web-search/executor.ts:65-66
parseSidecarSSE enforces a 64 KiB accepted-byte limit, processes complete SSE data, discards truncated decoder state, and cancels the reader without waiting. Related comments document the raw-byte limit and downstream display clamp.
Parser limit validation
tests/web-search-parse.test.ts:2-18, tests/web-search-parse.test.ts:27-115, tests/web-search-parse.test.ts:231-238
Tests cover exact-cap responses, incomplete events, truncated UTF-8 sequences, rejected cancellation promises, and reduced long Sources-header fixtures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SidecarStream
  participant parseSidecarSSE
  participant TextDecoder
  participant Reader
  SidecarStream->>parseSidecarSSE: provide streamed response chunks
  parseSidecarSSE->>TextDecoder: decode bytes below 64 KiB
  TextDecoder-->>parseSidecarSSE: return complete SSE data
  parseSidecarSSE->>Reader: cancel without waiting at byte limit
  parseSidecarSSE-->>SidecarStream: return bounded parsed output
Loading

Possibly related PRs

Suggested reviewers: lidge-jun, ingwannu, wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: bounding streamed sidecar response bytes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Wibias
Wibias marked this pull request as ready for review August 9, 2026 23:45
@luvs01

luvs01 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@github-actions[bot] Acknowledged. The PR gate reports that the readiness checklist passed at head 30adf56babc90d469312c215080b7974c3ebe5a8.

You are interacting with an AI system.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

@github-actions[bot] have exceeded the limit for the number of chat messages per hour. Please wait 48 minutes and 28 seconds before sending another message.

@Wibias
Wibias merged commit 1bd7218 into lidge-jun:dev Aug 10, 2026
31 of 35 checks passed

Wibias commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks @luvs01 — strong bounded-stream hardening here. Capping raw sidecar SSE before decoded/authoritative copies accumulate, while preserving complete events and cancellation semantics, closes the memory-growth path cleanly. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants