Skip to content

fix: handle raw Gemini and OCI requests in ATIF export - #1486

Merged
willkill07 merged 2 commits into
NVIDIA:mainfrom
bbednarski9:bbednarski/atif-raw-gemini-oci
Oct 23, 2026
Merged

willkill07 merged 2 commits into
NVIDIA:mainfrom
bbednarski9:bbednarski/atif-raw-gemini-oci

Conversation

@bbednarski9

@bbednarski9 bbednarski9 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

Fix raw Gemini and OCI GENERIC request handling in ATIF export. Native multimodal requests now produce readable user-step text, and raw Gemini tool responses continue the existing turn without creating a spurious user step.

The complete provider request, including image bytes and file references, remains in extra.llm_request. Display projection does not change the request sent to downstream model callbacks or the image-sensitive request signature.

  • 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

Raw provider display

  • Read the latest Gemini user contents[].parts, including the default user role when role is omitted. Join top-level text with newlines; exclude thought parts and nested function-response content.
  • Read OCI GENERIC uppercase USER messages and TEXT parts, supporting both bare requests and the chatRequest envelope.
  • Emit an empty string for image-only user messages instead of serializing the provider request or falling back to an earlier user's text.
  • Recognize OCI uppercase roles before generic chat turn classification, so valid USER messages are not suppressed as continuations.
  • Keep this display-only helper separate from extract_user_messages, which is used by request-signature matching. Distinct inline images and file references retain distinct signatures.

Raw Gemini continuation detection

  • Suppress the extra user step for paired calls whose latest user content contains function responses without fresh top-level user input.
  • Preserve a fresh user step when text, inlineData, or fileData accompanies a function response. Nested tool-result text and images do not count as fresh user input.
  • Recognize model messages as continuations and preserve existing unmatched-start behavior.

Scope and prerequisite

  • Branched from main (b4c3c9ac); this does not incorporate the implementation from fix: preserve readable ATIF user text with inline images #1483.
  • No public API or binding configuration changes. Annotation precedence remains unchanged; these changes address the raw-request fallback. Broader history/tool-result signature issues from the audit remain outside this PR.
  • A separate prerequisite commit adds the missing mut to the loaded TLS PEM binding in OpenTelemetryTlsConfig::validate. Main failed to compile with E0596 because TlsPem::http_client takes &mut self. This one-line correction enabled validation of the ATIF changes.
  • Document the raw-provider display and continuation behavior in the ATIF guide.

Validation

  • Three new Rust regression tests pass, covering bare/wrapped payloads, Gemini role omission, inline/file images, latest image-only turns, thought exclusion, tool-only versus mixed fresh input, OCI roles, unmatched starts, raw-request retention, distinct image signatures, and a chat compatibility control.
  • just test-rust: 6,488 passed; four skipped.
  • just test-python: 86 native, 1,205 runtime, and 24 plugin-example tests passed.
  • just test-node: six native, 521 runtime, and 26 plugin-example tests passed.
  • GOFLAGS=-count=1 just test-go: passed.
  • Offline Python downstream audit: 14 Gemini/OCI cases passed with and without codecs; all 28 callback payloads and original request objects were unchanged, and exported trajectories retained both original requests. This uses local callbacks, not live provider API calls.
  • uv run pre-commit run: passed, including formatting, documentation link checks, Clippy, Cargo checks, and dependency audits.

Where should the reviewer start?

Start with raw_provider_user_message, gemini_contents_turn_state, and request_turn_state_from_raw in atif.rs. The key boundary is that readable display extraction is separate from request-signature extraction.

Then review the three raw_provider_* / raw_gemini_tool_* tests at the end of crates/core/tests/unit/atif_tests.rs, which exercise the exporter and verify complete extra.llm_request retention.

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

Summary by CodeRabbit

  • Bug Fixes
    • Improved observability for raw Gemini and OCI requests: user-step messages now reflect visible user text, while Gemini thought content and tool-result details are excluded.
    • Better recognize when provider responses continue an existing turn versus start a new user step. Image-only user messages may start a new step without displaying text.
  • Documentation
    • Clarified how raw Gemini and OCI requests appear in observability, including how text, images, and tool responses affect user steps.

@bbednarski9
bbednarski9 requested review from a team as code owners October 23, 2026 19:36
@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 23, 2026
@coderabbitai

coderabbitai Bot commented Oct 23, 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 b4c3c9a and 030d5a7.

📒 Files selected for processing: 4
  • crates/core/src/observability/atif.rs
  • crates/core/src/observability/otel_tls.rs
  • crates/core/tests/unit/atif_tests.rs
  • docs/configure-plugins/observability/atif.mdx

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: 2
  • GitHub Check: Preview docs
  • GitHub Check: Changes / Detect
🧰 Additional context used
📚 Code guidelines: 4
.agents/skills/contribute-docs/SKILL.md — configured
RELEASING.md — auto-discovered
.agents/skills/maintain-observability/SKILL.md — configured
.agents/skills/review-doc-style/SKILL.md — configured
📓 Path-based instructions: 9
Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.

⚙️ CodeRabbit configuration file

Files:

  • docs/configure-plugins/observability/atif.mdx
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/atif_tests.rs
Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.

⚙️ CodeRabbit configuration file

Files:

  • crates/core/src/observability/otel_tls.rs
  • crates/core/tests/unit/atif_tests.rs
  • crates/core/src/observability/atif.rs
Source excerpt: In MDX files, top-of-file comments must use JSX comment delimiters: `{/*` to open and `*/}` to close.

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

Files:

  • docs/configure-plugins/observability/atif.mdx
Applicability reference: AGENTS.md: # NeMo Relay Repository Guidance Keep release-process policy in maintainer sources such as `RELEASING.md` and Source excerpt: Do not copy full GitHub Release notes into `CHANGELOG.md` or the docs site.

📄 CodeRabbit inference engine (RELEASING.md)

Files:

  • docs/configure-plugins/observability/atif.mdx
`crates/core/src/observability/atif.rs`

📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)

Files:

  • crates/core/src/observability/atif.rs
Source excerpt: Verify MDX files use JSX delimiters for top-of-file SPDX comments.

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

Files:

  • docs/configure-plugins/observability/atif.mdx
Source excerpt: Docs under `docs/about-nemo-relay/concepts/subscribers.mdx` and `docs/configure-plugins/observability/`

📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)

Files:

  • docs/configure-plugins/observability/atif.mdx
Source excerpt: Update and validate docs or examples when the public workflow, documented observability contract, or emitted output changed.

📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)

Files:

  • docs/configure-plugins/observability/atif.mdx
🔇 Additional comments: 4
crates/core/src/observability/otel_tls.rs: 1

93-93: LGTM!

crates/core/src/observability/atif.rs: 1

1028-1028: LGTM!

Also applies to: 1032-1100, 1104-1115, 1126-1130

crates/core/tests/unit/atif_tests.rs: 1

7171-7193: LGTM!

Also applies to: 7195-7299, 7301-7336, 7338-7357

docs/configure-plugins/observability/atif.mdx: 1

368-375: LGTM!

Walkthrough

Raw Gemini and OCI GENERIC requests now have provider-specific ATIF user-step projection and turn detection. Unit tests and documentation cover these rules. TLS validation also changes the mutability of its loaded PEM binding.

Changes

Raw provider ATIF handling

Layer / File(s) Summary
Raw provider projection and turn detection
crates/core/src/observability/atif.rs, crates/core/tests/unit/atif_tests.rs, docs/configure-plugins/observability/atif.mdx
Raw Gemini and OCI GENERIC requests use provider-specific rules to project user-step text and detect fresh turns or continuations. Tests cover text projection, image and thought handling, request retention, and turn detection. The documentation describes these rules.

TLS validation

Layer / File(s) Summary
PEM binding in validation
crates/core/src/observability/otel_tls.rs
OpenTelemetryTlsConfig::validate binds the loaded TlsPem as mutable. The HTTP-client validation call and result handling are unchanged.

Priority: ➖ Normal

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 030d5

No actionable merge-blocking risk was identified; the change is 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 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 3 files. (1 skipped: … 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 valid Conventional Commits format, includes the lowercase type "fix", clearly describes the raw Gemini and OCI ATIF changes, stays under 72 characters, and has no trailing period.
Description check Passed The description includes all required template sections, completed overview confirmations, detailed change information, reviewer guidance, related issues with valid action keywords, and validation res…
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: Description check

Explanation

The description includes all required template sections, completed overview confirmations, detailed change information, reviewer guidance, related issues with valid action keywords, and validation results.

Full details: Docstring Coverage

Explanation

Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 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.

@github-actions

Copy link
Copy Markdown

@willkill07
willkill07 merged commit 9069bca into NVIDIA:main Oct 23, 2026
97 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Oct 26, 2026
2 tasks done

This branch was previously deployed

1 inactive deployment
fern — 030d5a74 Deployed Oct 23, 2026 by willkill07 via Clean up docs preview #6491
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