Skip to content

fix: preserve tool-call correlation through trajectory redaction - #1569

Merged
willkill07 merged 1 commit into
NVIDIA:release/0.11from
bbednarski9:bbednarski/relay-1154-preserve-tool-call-ids
Oct 29, 2026
Merged

willkill07 merged 1 commit into
NVIDIA:release/0.11from
bbednarski9:bbednarski/relay-1154-preserve-tool-call-ids

Conversation

@bbednarski9

@bbednarski9 bbednarski9 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

With trajectory_context enabled, distinct model tool calls and tool execution events receive the same [REDACTED] correlation ID. ATIF consequently merges genuine tool results: two same-name calls produce one observation. Preserve the original tool-call correlation IDs while continuing to remove conversational content.

  • 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

  • Preserve correlation IDs in normalized response tool calls, request-side assistant calls and tool-result messages, tool-use/result content parts, and event category profiles.
  • Continue redacting response IDs, Responses item IDs, other application identifiers, arguments, results, descriptions, schemas, and unknown fields.
  • Add a managed-call regression that decodes two same-name tool calls through OpenAIChatCodec, executes them in reverse order, and checks ATIF plus OpenTelemetry Full, GenAI, and OpenInference output.
  • Exercise zero, one, and two trajectory profiles so repeated sanitization cannot collapse identities. Extend the typed request matrix to cover correlation IDs across supported message representations.
  • Document the correlation-ID preservation contract in the crate README. No exporter-specific workaround, hashing, mapping state, public API, or binding configuration changes.
  • This source fix is a prerequisite for the captured native-tool example in documentation PR docs: separate PII overview, configuration, and redaction behavior #1554. The website documentation changes remain in that PR.

Validation:

  • All 182 PII plugin tests passed during implementation. The native-tool sample also passed through actual managed LLM/tool calls using synthetic provider responses; application-facing values stayed unchanged.
  • All staged pre-commit hooks passed on current release/0.11, including Clippy, build checks, dependency audits, and link checking.
  • NEXTEST_TEST_THREADS=4 just test-rust passed on this release-based branch: 6,602 tests passed, 4 skipped. Reduced concurrency avoided the networking timeouts observed in the earlier parallel run.

Where should the reviewer start?

Start with crates/pii-redaction/tests/unit/trajectory_tool_correlation_tests.rs for the managed-call reproducer and exporter assertions. Then review the correlation-field preservation in crates/pii-redaction/src/trajectory.rs.

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

Summary by CodeRabbit

  • Bug Fixes
    • Trajectory exports now preserve tool-call IDs so tool requests and results remain correctly correlated, including when multiple calls have the same name or complete in a different order.
    • Response IDs and other application identifiers continue to be redacted. Repeated sanitization produces consistent results.
  • Documentation
    • Updated the trajectory export guidance to clarify which identifiers are preserved and which are replaced.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 11fd6ae and cab7595.

Files selected for processing: 4
  • crates/pii-redaction/README.md
  • crates/pii-redaction/src/trajectory.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
  • crates/pii-redaction/tests/unit/trajectory_tool_correlation_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: 4
  • GitHub Check: Apply PR labels
  • GitHub Check: request / require-nvskills-ci / require-nvskills-ci
  • GitHub Check: Prepare
  • GitHub Check: Detect docs changes
Additional context used
Code guidelines: 1
.agents/skills/contribute-integration/SKILL.md — configured
Path-based instructions: 2
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/pii-redaction/tests/unit/trajectory_tool_correlation_tests.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
Source excerpt: [ ] Integration pattern follows `docs/integrate-into-frameworks/adding-scopes.mdx` Source excerpt: Keep NeMo Relay optional Source excerpt: Use stable, documented framework or plugin APIs Source excerpt: Wrap tool and LLM pa...

CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)

Files:

  • crates/pii-redaction/README.md
  • crates/pii-redaction/tests/unit/trajectory_tool_correlation_tests.rs
  • crates/pii-redaction/src/trajectory.rs
  • crates/pii-redaction/tests/unit/component_tests.rs
Additional comments: 4
crates/pii-redaction/README.md: 1

159-159: LGTM!

Also applies to: 166-169

crates/pii-redaction/src/trajectory.rs: 1

164-165: LGTM!

Also applies to: 404-404, 407-407, 415-415, 421-421, 428-428, 433-433, 494-494, 499-499, 505-505, 510-510, 538-538, 723-723, 1141-1141

crates/pii-redaction/tests/unit/component_tests.rs: 1

71-73: LGTM!

Also applies to: 701-702, 707-707, 710-710, 712-713, 773-789, 910-910, 937-937

crates/pii-redaction/tests/unit/trajectory_tool_correlation_tests.rs: 1

1-202: LGTM!

Walkthrough

Trajectory sanitization now preserves tool-call correlation identifiers across messages, content parts, response calls, and category profiles. Response IDs and other application identifiers remain subject to replacement. Tests cover correlation across trajectory and telemetry output.

Changes

Trajectory tool-call correlation

Layer / File(s) Summary
Preserve correlation identifiers
crates/pii-redaction/src/trajectory.rs, crates/pii-redaction/README.md
Trajectory sanitization retains tool-call correlation IDs. The README distinguishes these IDs from response IDs and other application identifiers.
Verify sanitized output and correlation
crates/pii-redaction/tests/unit/component_tests.rs, crates/pii-redaction/tests/unit/trajectory_tool_correlation_tests.rs
Tests check that correlation IDs remain unchanged, response-message IDs remain redacted, and repeated sanitization is idempotent. Exporter tests check call correlation across reverse-order completions and telemetry projections.

Priority: Normal

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

Change: Bug fix

Possibly related PRs

  • NVIDIA/NeMo-Relay#1554: Documents trajectory PII redaction behavior and native-tool examples, which are also described in this PR.
Merge Risk: Minimal · up to cab75

Tool-call IDs remain available to correlate results as documented. No actionable merge-blocking issue remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… 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 uses the allowed type "fix" with a colon and a concise imperative summary (64 characters, under 72, no trailing period). It clearly describes the main change: preserving tool-call correlatio…
Description check Passed The description follows the repository template. It includes the Overview with both checklist items marked, a Details section listing the correlation-ID preservation changes, the regression test, the …
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.
Full details: Title check

Explanation

The title uses the allowed type "fix" with a colon and a concise imperative summary (64 characters, under 72, no trailing period). It clearly describes the main change: preserving tool-call correlation IDs during trajectory redaction, which matches the trajectory.rs changes, the tests, and the PR objectives. No breaking change is indicated, so no "!" suffix is needed.

Full details: Description check

Explanation

The description follows the repository template. It includes the Overview with both checklist items marked, a Details section listing the correlation-ID preservation changes, the regression test, the README update, and the validation results. It also has a Where should the reviewer start section naming the key test and source file, and a Related Issues section using the 'Relates to' keyword with RELAY-1154 and #1554. The template's 'Closes' example is not used, but 'Relates to' is one of the allowed action keywords, so the section is complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 3 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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.

@bbednarski9
bbednarski9 marked this pull request as ready for review October 29, 2026 16:42
@bbednarski9
bbednarski9 requested a review from a team as a code owner October 29, 2026 16:42
@github-actions github-actions Bot added size:M PR is medium Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code labels Oct 29, 2026
@willkill07 willkill07 added this to the 0.11 milestone Oct 29, 2026
@github-actions

Copy link
Copy Markdown

@willkill07
willkill07 merged commit af5e4be into NVIDIA:release/0.11 Oct 29, 2026
35 of 38 checks passed
willkill07 pushed a commit that referenced this pull request Oct 29, 2026
…1554)

#### Overview

The PII documentation mixes configuration lookup, detailed policy
behavior, and worked examples. Organize it into three pages: About
explains runtime placement and backend availability; Configuration
provides settings and complete examples; Redaction Behavior explains
selection, transformation, preservation, and match diagnostics.

**Dependency satisfied:** #1569 is merged into `release/0.11` and
included in this branch. The native-tool examples use its correlation-ID
preservation.

- [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

- Organize About around runtime placement, scope and mark events,
covered data, backend availability, an email example, policy selection,
and the middleware comparison. Keep the block diagram compatible with
Fern's renderer.
- Keep Configuration focused on grouped reference tables, codec
selection, configuration validation, profiles, surface flags,
local-backend fields, the detector catalog, and CLI setup.
- Add Redaction Behavior for payload boundaries and publication,
actions, detector matching, exact pointers and globs, trajectory
preservation, typed metrics, and selection accounting. Folder navigation
discovers the new page using its frontmatter position.
- Keep two tab groups with twelve complete worked examples on
Configuration, including captured native function-calling
requests/responses and separate tool events. Preserve the Worked
Examples jump link immediately before surface-flag guidance.
- Keep all content visible under normal headings. Preserve all 45
existing Configuration anchors beside links to moved material, and
update the affected cross-page and migration-guide references.
- Keep a short policy-verification section and diagnostic component-key
reference on Configuration.
- Qualify single-policy coverage of other scope events and typed
metric-name preservation in the email example.

Validation:
- `just docs` passed, including navigation and internal link validation.
All staged pre-commit hooks passed, including dependency audits and
external link checking.
- Verified that every worked-example TOML/JSON code block is unchanged
by the page split. The six native-tool JSON blocks match the
managed-call capture; application-facing requests and results remain
unchanged.
- Checked About, Configuration, and Redaction Behavior at desktop and
390-pixel widths: no page overflow or expandable content; both tab
groups and all twelve example tabs work.
- Verified the Worked Examples jump link, cross-page navigation into
Path Semantics, all 45 legacy Configuration anchors, and the new
cross-page fragment targets.
- Runtime validation for the correlation fix is recorded in #1569. This
PR changes documentation only.

#### Where should the reviewer start?

Read the three page introductions, then follow Configuration's Redaction
Behavior links into `redaction-behavior.mdx`. Check that settings and
examples remain easy to find and that the behavior guide contains the
detailed selection/preservation rules. Review the native-tool trajectory
example and the legacy Configuration anchor compatibility.

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

- Relates to [RELAY-1154](https://linear.app/nvidia/issue/RELAY-1154).
- Relates to #1549.
- Depends on #1569 (merged).

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

## Summary by CodeRabbit

* **Documentation**
* Reorganized the PII redaction guides to describe which observability
events are sanitized and how they differ from provider and tool requests
and application results.
* Expanded configuration guidance for profiles and single policies,
including codec behavior, validation, surface settings, backends,
actions, and policy ordering.
* Added examples and guidance for email redaction, path selection,
selector limitations, observability boundaries, and interpreting
diagnostics.
* Documented `local_model` as a runtime-provided extension point and
explained the distinction between the configuration-driven plugin and
raw sanitization middleware.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Bryan Bednarski <[email protected]>

This branch was previously deployed

1 inactive deployment
fern — cab75955 Deployed Oct 29, 2026 by willkill07 via Clean up docs preview #6772
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:M PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants