Skip to content

fix: bound Anthropic streaming content block storage - #1303

Merged
willkill07 merged 1 commit into
NVIDIA:release/0.10from
willkill07:fix/relay-1034-anthropic-block-storage
Oct 13, 2026
Merged

willkill07 merged 1 commit into
NVIDIA:release/0.10from
willkill07:fix/relay-1034-anthropic-block-storage

Conversation

@willkill07

@willkill07 willkill07 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Overview

Bound Anthropic streaming content block storage while preserving response assembly and public APIs. Large or sparse indices previously allocated every intervening vector slot.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • Keep dense storage for indices 0–2047 and use an ordered sparse map for indices 2048 and above, including the full unsigned index range.
  • Preserve numeric block ordering, replacement on repeated starts, delta assembly, and ignored deltas for blocks that have not started.
  • Add regression coverage for the dense/sparse boundary, extreme indices, ordering, and replacement in both stores. The extreme-index test checks a small sparse index first so a storage regression fails safely.
  • No breaking API changes or binding changes.

Validation: all 12 focused Anthropic streaming tests and staged repository hooks passed, including formatting, Clippy, Cargo checks, and dependency audits. just test-rust ran 5,816 tests: 5,814 passed initially; the two CLI diagnostic failures passed when rerun with isolated system configuration and inherited logging overrides removed. One timeout test passed on retry. Python, Node.js, and Go suites were not run because their API and assembly contracts are unchanged.

Where should the reviewer start?

Start with AnthropicMessagesStreamingState in crates/core/src/codec/anthropic.rs for the storage split and ordered finalization, then review the three new streaming regressions in crates/core/tests/unit/codec/anthropic_tests.rs.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of Anthropic streaming responses with content blocks at very high indices, avoiding excessive memory growth.
    • Finalized content now preserves block order, and repeated starts correctly replace blocks at the same index. Deltas for blocks that were never started are no longer included in the finalized response.

@willkill07
willkill07 requested a review from a team as a code owner October 13, 2026 12:54
@github-actions github-actions Bot added size:S PR is small Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code labels Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/NeMo-Relay/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: 227ff391-30cc-45a2-84d0-dac4e2c1711b
📥 Commits

Reviewing files that changed from the base of the PR and between 2747f4a and 946d70d.

📒 Files selected for processing (2)
  • crates/core/src/codec/anthropic.rs
  • crates/core/tests/unit/codec/anthropic_tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (44)
  • GitHub Check: Python / Package (macos-arm64)
  • GitHub Check: Python / Package (windows-arm64)
  • GitHub Check: Python / Package (linux-musl-arm64)
  • GitHub Check: Python / Test (linux-arm64)
  • GitHub Check: Python / Test (windows-amd64)
  • GitHub Check: Python / Test (macos-arm64)
  • GitHub Check: Python / Test (linux-amd64)
  • GitHub Check: Go / Test (windows-amd64)
  • GitHub Check: Python / Package (linux-arm64)
  • GitHub Check: Rust / Package (linux-musl-arm64)
  • GitHub Check: Rust / Package (windows-arm64)
  • GitHub Check: Node.js / Package (linux-musl-arm64)
  • GitHub Check: Rust / Package (linux-musl-amd64)
  • GitHub Check: Node.js / Package (windows-amd64)
  • GitHub Check: Python / Test (windows-arm64)
  • GitHub Check: Python / Package (windows-amd64)
  • GitHub Check: Go / Test (linux-arm64)
  • GitHub Check: Go / Test (macos-arm64)
  • GitHub Check: Python / Package (linux-musl-amd64)
  • GitHub Check: Node.js / Test (windows-arm64)
  • GitHub Check: Go / Test (linux-amd64)
  • GitHub Check: Node.js / Package (macos-arm64)
  • GitHub Check: Rust / Package (macos-arm64)
  • GitHub Check: Python / Package (linux-amd64)
  • GitHub Check: Node.js / Package (linux-amd64)
  • GitHub Check: Go / Test (windows-arm64)
  • GitHub Check: Node.js / Package (linux-musl-amd64)
  • GitHub Check: Node.js / Test (linux-amd64)
  • GitHub Check: Rust / Package (linux-amd64)
  • GitHub Check: Node.js / Package (windows-arm64)
  • GitHub Check: Rust / Test (windows-arm64)
  • GitHub Check: Node.js / Package (linux-arm64)
  • GitHub Check: Rust / Package (windows-amd64)
  • GitHub Check: Node.js / Test (macos-arm64)
  • GitHub Check: Rust / Test (windows-amd64)
  • GitHub Check: Rust / Package (linux-arm64)
  • GitHub Check: Node.js / Test (windows-amd64)
  • GitHub Check: Node.js / Test (linux-arm64)
  • GitHub Check: Rust / Test (linux-amd64)
  • GitHub Check: Node.js / Package OpenClaw plugin
  • GitHub Check: Rust / Test (macos-arm64)
  • GitHub Check: Rust / Test (linux-arm64)
  • GitHub Check: Check / Run
  • GitHub Check: Preview docs
🧰 Additional context used
📚 Code guidelines (1)
CONTRIBUTING.md — configured
📓 Path-based instructions (4)
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

⚙️ CodeRabbit configuration file

Files:

  • crates/core/tests/unit/codec/anthropic_tests.rs
Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.

⚙️ CodeRabbit configuration file

Files:

  • crates/core/tests/unit/codec/anthropic_tests.rs
  • crates/core/src/codec/anthropic.rs
Source excerpt: **Formatting**: `cargo fmt` (rustfmt defaults) Source excerpt: **Linting**: `cargo clippy -- -D warnings` -- all warnings are treated as errors

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • crates/core/tests/unit/codec/anthropic_tests.rs
  • crates/core/src/codec/anthropic.rs
Source excerpt: Use the naming conventions appropriate to each language: Rust `snake_case`, C FFI exports prefixed `nemo_relay_`, Go `PascalCase`, Node.js `camelCase`, Python `snake_case`.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • crates/core/tests/unit/codec/anthropic_tests.rs
  • crates/core/src/codec/anthropic.rs
🔇 Additional comments (2)
crates/core/src/codec/anthropic.rs (1)

1298-1306: LGTM!

Also applies to: 1378-1389, 1400-1409, 1499-1505

crates/core/tests/unit/codec/anthropic_tests.rs (1)

1492-1599: LGTM!

Walkthrough

The Anthropic streaming codec now stores block indices below 2048 densely and higher indices in an ordered map. It routes block starts and deltas to the matching storage and emits finalized blocks in index order. Tests cover large indices, the storage boundary, repeated starts, and unstarted-index deltas.

Changes

Anthropic streaming block storage

Layer / File(s) Summary
Dense and sparse block routing
crates/core/src/codec/anthropic.rs
The streaming state uses dense storage for indices below 2048 and a BTreeMap for higher indices. Block starts and deltas use the storage selected by index.
Ordered finalization and coverage
crates/core/src/codec/anthropic.rs, crates/core/tests/unit/codec/anthropic_tests.rs
Finalization emits dense blocks followed by sparse blocks in index order. Tests cover large indices, the 2048 boundary, repeated starts, and deltas for unstarted indices.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 946d7

No actionable merge-blocking issue is identified; the change appears ready for normal merge checks.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title follows Conventional Commits format with the allowed lowercase type "fix", uses an imperative summary, is 52 characters long, and has no trailing period. It accurately describes the storage-…
Description check Passed The description includes all required sections, confirms the checklist items, explains the implementation and validation, identifies review starting points, and links the related issue with the "Fixes…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

Copy link
Copy Markdown

@willkill07 willkill07 self-assigned this Oct 13, 2026
@willkill07 willkill07 added this to the 0.10 milestone Oct 13, 2026
@willkill07
willkill07 merged commit 47b545b into NVIDIA:release/0.10 Oct 13, 2026
97 checks passed
willkill07 added a commit that referenced this pull request Oct 14, 2026
#### Overview

Add 0.10.1 release notes covering the fifteen PRs merged into
`release/0.10` since `0.10.0`, plus the anticipated merge of #1317, with
matching patch-upgrade guidance. Preserve the 0.10.0 notes and follow
the NVIDIA documentation style guide.

- [x] I confirm this contribution is my own work, or I have the right to
submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does
not duplicate existing work.

#### Details

- Cover daemon-worker LLM middleware (#1281), the YAML dependency update
(#1282), hook timeout and failure-policy fixes (#1288, #1289, #1290),
and request-edit preservation (#1296).
- Cover Anthropic streaming storage (#1303), Python typed reconstruction
(#1304), Go native handle lifetimes (#1302), authenticated Pi hooks and
session ownership (#1306), dynamic plugin trust failures (#1305), and
verified native plugin loading (#1307).
- Cover Pi named-upstream restrictions (#1314), LangChain tool-schema
edits (#1316), and the configurable ChatGPT Codex endpoint (#1319).
- Assume #1317 will merge: document plugin HTTP error helpers and
prefixes, preservation of remote Guardrails and forwarded hook HTTP
error statuses, verified reporting identities, and streaming limits.
Verified against its current head
`b61bb7da0bc6de7b7d5d27a569981867b7b2fcb9`; its implementation is not
merged into this branch.
- Add upgrade guidance for hook credentials and registration, generated
hooks, daemon response behavior, request edits, Pi extensions and
private provider endpoints, native plugin dependencies, stored Python
typed values, ChatGPT endpoints, and HTTP error handling.
- Keep PR references and counts out of user-facing release notes.
Preserve the prior CodeRabbit corrections for MCP route registration,
forwarded-stream observation limits, sanitizer-only behavior, and 0.10.1
installation pins.
- Merge the latest `release/0.10` into the PR branch. Distinguish
personal hook refresh commands from administrator-managed daemon
bundles.

Validation: `just docs`, `uv run pre-commit run`, and `git diff --cached
--check` passed. Fern skipped the published redirect-history check
because FDR returned HTTP 403. Verified the merged release range against
source and public documentation, and the assumed #1317 behavior against
its current PR source and docs.
Language test suites were not run because the PR diff only updates
documentation prose and installation version pins. Package installation
commands, live daemon upgrades, plugin activations, and hook refreshes
were not executed. Validation runs on the current release branch; #1317
remains an explicit release-content assumption.

#### Where should the reviewer start?

Start with `Release 0.10.1` in
`docs/about-nemo-relay/release-notes/index.mdx`, then review `Update
from NeMo Relay 0.10.0 to 0.10.1` in
`docs/reference/migration-guides.mdx`. Review the new Pi endpoint,
ChatGPT endpoint, LangChain tool-edit, and HTTP error guidance,
including the #1317 merge assumption. Check matching version pins in
`docs/getting-started/installation.mdx`.

#### Related Issues: (use one of the action keywords Closes / Fixes /
Resolves / Relates to)

- Relates to: none


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Added NeMo Relay 0.10.0 and 0.10.1 release notes, including feature
highlights, compatibility updates, fixes, and known issues.
* Expanded migration guidance with upgrade steps and details on hook
credentials and delivery, daemon-worker middleware behavior, request
editing, plugin requirements, and Python value handling.
* Updated installation examples across supported platforms, packages,
and integrations to reference version 0.10.1.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Will Killian <[email protected]>
@willkill07
willkill07 deleted the fix/relay-1034-anthropic-block-storage branch October 30, 2026 14:47

This branch was previously deployed

1 inactive deployment
fern — 946d70d5 Deployed Oct 13, 2026 by willkill07 via Clean up docs preview #5645
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code size:S PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants