Repository navigation
feat!: add borrowed normalized codec content views across Rust and language bindings APIs - #1730
Closed
bbednarski9 wants to merge 41 commits into
Closed
bbednarski9 wants to merge 41 commits into
bbednarski9 wants to merge 41 commits into
Conversation
Expose consistent typed traversal and text extraction for normalized request items and response output. BREAKING CHANGE: normalized text helpers return Option<Cow<str>>, join all text/refusal parts, and retain textless selection boundaries. Signed-off-by: Bryan Bednarski <[email protected]>
Contributor
Recognize Chat, Responses, and Anthropic message roles consistently when extension fields keep requests provider-native. Preserve payloads and textless selection boundaries, and exclude tool envelopes and metadata from text projection. Signed-off-by: Bryan Bednarski <[email protected]>
Normalize OpenAI Chat and Responses refusals as typed content, accumulate Chat refusal deltas, and preserve refusal fields through PII overlays. Signed-off-by: Bryan Bednarski <[email protected]>
Signed-off-by: Bryan Bednarski <[email protected]>
Signed-off-by: Bryan Bednarski <[email protected]>
Signed-off-by: Bryan Bednarski <[email protected]>
Signed-off-by: Bryan Bednarski <[email protected]>
Signed-off-by: Bryan Bednarski <[email protected]>
Preserve multipart text and refusals without falling back to raw provider payloads. Keep empty annotations authoritative and retain existing media, opaque content, tool-call, and usage projections. Signed-off-by: Bryan Bednarski <[email protected]>
Share text and refusal traversal for normalized instructions, history content, and response output. Keep trim and empty-content display rules, preserve JSON text literally, and exclude native reasoning, media, and tool payloads from default message text. Signed-off-by: Bryan Bednarski <[email protected]>
Traverse normalized output through the borrowed view while retaining the explicit text/refusal allowlist. Reuse joined strings when building fresh provider projections and keep native values, media, and tool payloads excluded. Signed-off-by: Bryan Bednarski <[email protected]>
Render OpenAI Chat content and refusal fields separately and preserve ordered text/refusal blocks in Responses. Retain empty values, fresh allowlisted payloads, and safe tool and usage projections; cover both response and event sanitizer paths. Signed-off-by: Bryan Bednarski <[email protected]>
Keep profile and prompt IR rendering policies distinct while sharing normalized part traversal. Preserve existing fingerprints, empty-part behavior, and structured payload rendering without allocating an intermediate string vector. Signed-off-by: Bryan Bednarski <[email protected]>
Retain media fingerprints and canonical structured values in prompt analysis, preserve block mapping and source-request reuse guards, and decline token-based hints when opaque costs are unknown. BREAKING CHANGE: BlockContentType adds StructuredInput and Opaque. ACG learning and bootstrap state uses the ::acg-ir=2 namespace and warms up independently of older records. Signed-off-by: Bryan Bednarski <[email protected]>
bbednarski9
marked this pull request as ready for review
November 13, 2026 03:40
Signed-off-by: Bryan Bednarski <[email protected]>
Signed-off-by: Bryan Bednarski <[email protected]>
Signed-off-by: Bryan Bednarski <[email protected]>
Signed-off-by: Bryan Bednarski <[email protected]>
Contributor
There was a problem hiding this comment.
Can we please update this list to include content.rs? This PR adds it, so there are now four files instead of three.
Collaborator
Author
There was a problem hiding this comment.
Added content.rs to the conversion table and removed the hard-coded file count in d6afa90. The table now lists all four modules.
mnajafian-nv
approved these changes
Nov 20, 2026
mnajafian-nv
left a comment
Contributor
There was a problem hiding this comment.
lgtm plus a minor suggestion above :)
Signed-off-by: Bryan Bednarski <[email protected]>
Signed-off-by: Bryan Bednarski <[email protected]>
Signed-off-by: Bryan Bednarski <[email protected]>
Signed-off-by: Bryan Bednarski <[email protected]>
…lays Signed-off-by: Bryan Bednarski <[email protected]>
2 tasks done
bbednarski9
added a commit
that referenced
this pull request
Nov 23, 2026
…t and language bindings APIs (#1800) > [!WARNING] > **Breaking changes in v1.0.0.** Rust’s `system_prompt()`, `last_user_message()`, and `response_text()` now return `Option<Cow<'_, str>>`. Keep the result alive and call `.as_deref()` to borrow its text, or use `.map(Cow::into_owned)` to keep an owned string. Exhaustive matches on `BlockContentType` must handle `StructuredInput` and `Opaque`. > > The text helpers now join all eligible text and refusal parts in the selected item. OpenAI Chat and Responses annotations containing a refusal expose typed parts at `/message`. Consumers that assumed a string must handle that shape. [Text helper migration](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/docs/integrate-into-frameworks/provider-codecs.mdx#migrate-existing-text-helpers) · [OpenAI redaction policy migration](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/docs/reference/migration-guides.mdx#update-openai-response-redaction-policies) First layer of the codec refactor. The original review discussion and approvals are in #1730. #### Overview This is the first PR in the v1.0.0 codec refactor. Rust provides borrowed views of normalized request history and response output. Python, Node.js, C, and Go expose owned snapshots with the same selection and text extraction rules. Rust and standalone Python workers can request a snapshot from the host through the new `InspectLlmContent` RPC. The shared traversal lets observability, PII redaction, and adaptive prompt analysis distinguish text and refusals from tool payloads, media, and provider-native content. Provider decoders and stream aggregators now retain content these consumers previously lost. The daemon validates stream completion before publishing an observation. - [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 **1. Shared normalized content API — `crates/types`** [content.rs](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/crates/types/src/codec/content.rs) introduces `MessageView`, `ContentEntry`, `ContentKind`, borrowed tool views, `PayloadRef`, and normalized source locations. | Entry point | Selection | | --- | --- | | `AnnotatedLlmRequest::last_message()` | Exactly the final supplied request item; instructions remain separate | | `AnnotatedLlmResponse::output()` | Current normalized message plus separate response tool calls | | `Message::content_view()` | Any selected history item | | `MessageContent::content_view()` | Standalone content, including instructions | Each view offers `parts()`, `text_parts()`, and `text()`: - Typed traversal distinguishes text, refusals, tool calls/results, images, audio, files, and opaque provider-native content. Tool payloads retain string versus parsed JSON representations without parsing or serializing during traversal. - Content-array order is preserved. Separate assistant/response tool calls follow content and retain their field identity; this does not reconstruct provider-wire order. - Default text includes text/refusals and supported shallow native fallbacks. It excludes tool payloads, reasoning, media, and arbitrary nested metadata. Recognized native request messages, including OpenAI Responses message content, expose their known content rather than disappearing from extraction. - No eligible text returns `None`; an explicit empty string remains present. Whitespace and empty parts survive newline joining. Selection never searches backward for another item with text. - Forward-only iterators advance through the selection once. Traversal borrows the source without cloning payloads or building a parts vector. `text()` borrows one string and allocates only to join multiple strings. Locations identify current normalized fields/indices, not stable edit handles. ```mermaid flowchart TD R["Provider request payload"] --> D["Request codec"] B["Buffered provider response"] --> E["Response codec"] S["Provider SSE events"] --> V["Completion validation"] V --> A["Provider streaming aggregation"] A --> E D --> N["Normalized request / response"] E --> N N --> M["Borrowed MessageView"] M --> P["Typed parts + source locations"] M --> T["Default text extraction: text + refusals"] T --> H["Rust text helpers"] M --> F["Owned snapshots for Python, Node.js, C, and Go"] M --> W["Host-generated snapshots for worker plugins"] T --> O["ATIF / OpenInference display policies"] P --> X["PII projection: explicit sanitized text/refusals only"] P --> C["Adaptive analysis: typed structured values + media fingerprints"] C --> K["Stability and cache planning"] K --> G["Require supplied token counts across opaque/media blocks"] ``` The diagram shows the shared read surface, not a new retained conversation context. Request views see supplied history; response views see current normalized output. Consumers keep their own display, privacy, and analysis policies. **2. Preserve content before extraction — `crates/codecs` and daemon worker observation** - **OpenAI Chat:** normalize `message.refusal` as typed refusal content and accumulate streamed refusal deltas, including explicit empty strings. Preserve streamed `system_fingerprint`, `service_tier`, and per-choice text/refusal logprob entries. - **OpenAI Responses:** retain typed refusal blocks and their order alongside ordinary text. Text-only responses retain their existing string representation. Streaming aggregation retains provisional text, refusals, and function arguments for supplied output items. Completed fields/parts/items replace provisional data; a nonempty terminal output is authoritative, preventing duplication. - **Gemini:** retain streamed `promptFeedback` and avoid inventing a candidate when a blocked prompt produced none. - **Daemon worker:** apply the streaming codec's completion validator during observation, use its borrowed collector when available, and close the validation stream. A missing terminal event invalidates the observation aggregate. Preserve cancellation/body-error outcomes when EOF races delivery completion. Validation runs off the application delivery path. A finalizer can expose partial Responses output, but partial aggregation does not establish successful completion. The worker omits invalid/truncated aggregates; forwarded response bytes are unchanged. **3. Adopt shared traversal in production consumers** | Module | Resulting behavior | | --- | --- | | `crates/observability/src/atif.rs` | Join annotated response text/refusals. Textless annotations remain empty instead of recovering raw tool text. Keep existing raw rendering for media/opaque responses and separate tool/usage projections. | | `crates/observability/src/openinference.rs` | Share extraction for normalized instructions, history content, and output; trim display text and omit empty attributes. JSON-looking normalized text stays literal. Tool messages/calls retain separate projections. | | `crates/pii-redaction/src/trajectory_projection.rs` | Project only explicit sanitized text/refusal kinds. Native fallback text is deliberately excluded. Preserve empty versus absent text and avoid interpreting strings as JSON. | | `crates/pii-redaction/src/overlay.rs` | Preserve sanitized OpenAI Chat refusal fields and OpenAI Responses refusal blocks instead of flattening them into ordinary text. | Chat projections join text and refusals within their separate fields; Responses projections preserve ordered text/refusal blocks. Other provider projections retain their existing newline-joined rendering. Existing string redaction actions targeting `/message` also sanitize text and refusal fields in multipart OpenAI responses. If removing parts prevents the sanitizer from preserving their positions, it omits the response payload. **4. Correct adaptive prompt identity and cache planning — `crates/adaptive`** The profile and prompt IR builders share borrowed traversal while keeping distinct fingerprinting/rendering policies. - Canonical structured input preserves meaningful string whitespace: `"New York"` and `"New York"` remain different. Tool arguments, structured tool results, and schema strings retain their structured identity. - Media and provider-native input contribute typed fingerprints. Changing an image therefore changes analyzed identity instead of appearing to be the same text-only prompt. Opaque fingerprints are excluded from variable extraction. - Stability scoring, prefix comparison, and diagnostic exemplar hashes use typed block identity, distinguishing identical bytes with different content kinds. - Existing message/block boundaries and span IDs remain aligned with provider hint application. Analysis representations are not sent to providers; the full source-request reuse guard remains in place. - Economics stops considering prefixes at the first opaque/media block without supplied token metadata. Anthropic translation declines breakpoints spanning those blocks rather than estimating tokens from fingerprint characters. Supplied counts remain supported. - Learning observations and aggregate/bootstrap state use the `::acg-ir=2` namespace. Old state remains stored but is not loaded or mixed with the new representation. **5. Expose owned snapshots across bindings and worker plugins** | Surface | How callers inspect content | | --- | --- | | Python | `nemo_relay.codecs.MessageView` owns the selection. Entries and iterators can outlive the annotation. | | Node.js and TypeScript | The published `nemo-relay-node` metapackage exports the `codecs` namespace with typed selection helpers, entries, and payloads. | | C and Go (experimental) | C callers inspect normalized JSON with `nemo_relay_inspect_llm_content_json` and release the result with `nemo_relay_string_free`. Go’s `InspectLLMContent` returns a typed, Go-owned snapshot that can outlive the codec callback. | | Rust and standalone Python workers | One authenticated `InspectLlmContent` RPC per selection returns explicit absence or a complete owned snapshot. Subsequent reads are local. Older hosts return `UNIMPLEMENTED`. | The worker protocol adds typed protobuf mappings for selections, locations, and snapshots in `src/conversions/content.rs`. Existing v1 methods and protocol identity are preserved. [Binding examples](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/docs/integrate-into-frameworks/provider-codecs.mdx#python-content-snapshots) · [Worker protocol contract](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/crates/worker-proto/CONTRACT.md#normalized-content-inspection) **Compatibility and migration** - **Rust source change:** `system_prompt()`, `last_user_message()`, and `response_text()` now return `Option<Cow<'_, str>>` instead of `Option<&str>`. Use `.as_deref()` for borrowed use or `Cow::into_owned` when ownership is required. - **Selection behavior:** `system_prompt()` selects top-level instructions, otherwise the first system/developer item; `last_user_message()` selects the last user item; `response_text()` selects current output. All collect eligible text/refusal parts, without skipping a selected textless item. - **Python:** existing text helpers continue to return `str | None` and inherit the multipart selection behavior. - **Rust adaptive enum:** exhaustive matches on `BlockContentType` must handle the new `StructuredInput` and `Opaque` variants. - **Adaptive persistence:** upgraded agents warm up from fresh samples under the versioned namespace. - Normalized type schemas/serialization contracts and codec traits are unchanged; decoded values now retain the refusal content described above. Existing provider normalization can still combine text blocks, including Anthropic, and the views expose the representation available today. Live streaming extraction APIs, general mutable/redaction APIs, broader binding APIs, comprehensive decoder fidelity changes, and allocation benchmark targets remain outside this PR. **Validation** - After merging `main` at PR revision `6bd64dc9c`, `just test-rust` passed 6,771 tests with 4 skipped. All 71 focused managed-worker tests also passed. - The local Go suite passed after the C and Go bindings landed. Earlier local Python, Node.js, and documentation suites passed. [CI results on the original PR at this revision](https://github.com/NVIDIA/NeMo-Relay/pull/1730/checks) - At documentation revision `d6afa9016`, the staged documentation checks passed. The dependency audit flagged the existing `wcmatch` 11.0 lockfile entry. [GHSA-53pm-wgxf-c6qf](GHSA-53pm-wgxf-c6qf) Regression coverage includes all built-in provider fixtures, borrowed versus owned text, normalized locations and serialization, native request fallbacks, multipart/refusal ordering, tool-only/textless selections, buffered/streamed refusal parity, stream completion/cancellation races, consumer-specific projection policies, typed adaptive identity, unknown media token costs, persistence isolation, and cache hints applied to unchanged original provider content. #### Where should the reviewer start? 1. [Shared content API](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/crates/types/src/codec/content.rs) and [content-view tests](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/crates/types/tests/content_views.rs): selection, borrowing, typed payloads, and extraction boundaries. 2. [Provider fixture coverage](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/crates/codecs/tests/content_views.rs), [refusal regressions](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/crates/codecs/tests/refusal_content.rs), then the three changed provider implementations and worker observation. 3. Consumer adoption in ATIF, OpenInference, and PII projection: check their intentionally different display/privacy policies. 4. [Adaptive IR builder](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/crates/adaptive/src/acg/ir_builder.rs), its tests, token estimation, and persisted-state versioning. 5. [Codec migration documentation](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/docs/integrate-into-frameworks/provider-codecs.mdx) and the adaptive/observability/PII documentation for externally visible behavior. 6. [Owned snapshot and shared selection](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/crates/types/src/codec/content_snapshot.rs), [worker wire conversions](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/crates/worker-proto/src/conversions/content.rs), and [Go binding tests](https://github.com/NVIDIA/NeMo-Relay/blob/09117da4decd987bd01f4ae371f1d6e1d494baed/go/nemo_relay/content_test.go) for the cross-language contract. #### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to) - Relates to: Support "text" extraction APIs — implemented for buffered normalized content and existing delegated helpers. No issue number was supplied, so no automatic closing reference is added. - Relates to: PII redaction from codec traits + APIs — groundwork and existing projection fixes only; the general redaction/editing API remains open. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added normalized content views across Rust, Python, Node.js/TypeScript, C, and Go, with typed parts, selection helpers, and owned snapshots. * Added host-backed content inspection for worker plugins, including Python worker helpers. * **Bug Fixes** * Cache planning now stops when token counts are unavailable for media or opaque content. * Improved preservation of OpenAI refusal content, response metadata, and partial streaming output; invalid or incomplete streams are reported more accurately. * Redaction and observability better preserve text/refusal boundaries, and adaptive state now uses a versioned namespace. * **Documentation** * Added guides for normalized content access, worker inspection, and codec behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Bryan Bednarski <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
Breaking changes in v1.0.0. Rust’s
system_prompt(),last_user_message(), andresponse_text()now returnOption<Cow<'_, str>>. Keep the result alive and call.as_deref()to borrow its text, or use.map(Cow::into_owned)to keep an owned string. Exhaustive matches onBlockContentTypemust handleStructuredInputandOpaque.The text helpers now join all eligible text and refusal parts in the selected item. OpenAI Chat and Responses annotations containing a refusal expose typed parts at
/message. Consumers that assumed a string must handle that shape. Text helper migration · OpenAI redaction policy migrationOverview
This is the first PR in the v1.0.0 codec refactor. Rust provides borrowed views of normalized request history and response output. Python, Node.js, C, and Go expose owned snapshots with the same selection and text extraction rules. Rust and standalone Python workers can request a snapshot from the host through the new
InspectLlmContentRPC.The shared traversal lets observability, PII redaction, and adaptive prompt analysis distinguish text and refusals from tool payloads, media, and provider-native content. Provider decoders and stream aggregators now retain content these consumers previously lost. The daemon validates stream completion before publishing an observation.
Details
1. Shared normalized content API —
crates/typescontent.rs introduces
MessageView,ContentEntry,ContentKind, borrowed tool views,PayloadRef, and normalized source locations.AnnotatedLlmRequest::last_message()AnnotatedLlmResponse::output()Message::content_view()MessageContent::content_view()Each view offers
parts(),text_parts(), andtext():None; an explicit empty string remains present. Whitespace and empty parts survive newline joining. Selection never searches backward for another item with text.text()borrows one string and allocates only to join multiple strings. Locations identify current normalized fields/indices, not stable edit handles.flowchart TD R["Provider request payload"] --> D["Request codec"] B["Buffered provider response"] --> E["Response codec"] S["Provider SSE events"] --> V["Completion validation"] V --> A["Provider streaming aggregation"] A --> E D --> N["Normalized request / response"] E --> N N --> M["Borrowed MessageView"] M --> P["Typed parts + source locations"] M --> T["Default text extraction: text + refusals"] T --> H["Rust text helpers"] M --> F["Owned snapshots for Python, Node.js, C, and Go"] M --> W["Host-generated snapshots for worker plugins"] T --> O["ATIF / OpenInference display policies"] P --> X["PII projection: explicit sanitized text/refusals only"] P --> C["Adaptive analysis: typed structured values + media fingerprints"] C --> K["Stability and cache planning"] K --> G["Require supplied token counts across opaque/media blocks"]The diagram shows the shared read surface, not a new retained conversation context. Request views see supplied history; response views see current normalized output. Consumers keep their own display, privacy, and analysis policies.
2. Preserve content before extraction —
crates/codecsand daemon worker observationmessage.refusalas typed refusal content and accumulate streamed refusal deltas, including explicit empty strings. Preserve streamedsystem_fingerprint,service_tier, and per-choice text/refusal logprob entries.promptFeedbackand avoid inventing a candidate when a blocked prompt produced none.A finalizer can expose partial Responses output, but partial aggregation does not establish successful completion. The worker omits invalid/truncated aggregates; forwarded response bytes are unchanged.
3. Adopt shared traversal in production consumers
crates/observability/src/atif.rscrates/observability/src/openinference.rscrates/pii-redaction/src/trajectory_projection.rscrates/pii-redaction/src/overlay.rsChat projections join text and refusals within their separate fields; Responses projections preserve ordered text/refusal blocks. Other provider projections retain their existing newline-joined rendering. Existing string redaction actions targeting
/messagealso sanitize text and refusal fields in multipart OpenAI responses. If removing parts prevents the sanitizer from preserving their positions, it omits the response payload.4. Correct adaptive prompt identity and cache planning —
crates/adaptiveThe profile and prompt IR builders share borrowed traversal while keeping distinct fingerprinting/rendering policies.
"New York"and"New York"remain different. Tool arguments, structured tool results, and schema strings retain their structured identity.::acg-ir=2namespace. Old state remains stored but is not loaded or mixed with the new representation.5. Expose owned snapshots across bindings and worker plugins
nemo_relay.codecs.MessageViewowns the selection. Entries and iterators can outlive the annotation.nemo-relay-nodemetapackage exports thecodecsnamespace with typed selection helpers, entries, and payloads.nemo_relay_inspect_llm_content_jsonand release the result withnemo_relay_string_free. Go’sInspectLLMContentreturns a typed, Go-owned snapshot that can outlive the codec callback.InspectLlmContentRPC per selection returns explicit absence or a complete owned snapshot. Subsequent reads are local. Older hosts returnUNIMPLEMENTED.The worker protocol adds typed protobuf mappings for selections, locations, and snapshots in
src/conversions/content.rs. Existing v1 methods and protocol identity are preserved. Binding examples · Worker protocol contractCompatibility and migration
system_prompt(),last_user_message(), andresponse_text()now returnOption<Cow<'_, str>>instead ofOption<&str>. Use.as_deref()for borrowed use orCow::into_ownedwhen ownership is required.system_prompt()selects top-level instructions, otherwise the first system/developer item;last_user_message()selects the last user item;response_text()selects current output. All collect eligible text/refusal parts, without skipping a selected textless item.str | Noneand inherit the multipart selection behavior.BlockContentTypemust handle the newStructuredInputandOpaquevariants.Live streaming extraction APIs, general mutable/redaction APIs, broader binding APIs, comprehensive decoder fidelity changes, and allocation benchmark targets remain outside this PR.
Validation
mainat PR revision6bd64dc9c,just test-rustpassed 6,771 tests with 4 skipped. All 71 focused managed-worker tests also passed.d6afa9016, the staged documentation checks passed. The dependency audit flagged the existingwcmatch11.0 lockfile entry. GHSA-53pm-wgxf-c6qfRegression coverage includes all built-in provider fixtures, borrowed versus owned text, normalized locations and serialization, native request fallbacks, multipart/refusal ordering, tool-only/textless selections, buffered/streamed refusal parity, stream completion/cancellation races, consumer-specific projection policies, typed adaptive identity, unknown media token costs, persistence isolation, and cache hints applied to unchanged original provider content.
Where should the reviewer start?
Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit
New Features
Documentation