Skip to content

fix: emit text-only ATIF step messages as strings - #1321

Merged
willkill07 merged 2 commits into
NVIDIA:mainfrom
fernandol-nvidia:fix/atif-text-message
Oct 14, 2026
Merged

willkill07 merged 2 commits into
NVIDIA:mainfrom
fernandol-nvidia:fix/atif-text-message

Conversation

@fernandol-nvidia

@fernandol-nvidia fernandol-nvidia commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Emit text-only ATIF step messages as a string, as the ATIF spec defines. Messages with images keep #1301's ContentPart[].

  • 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

ATIF (RFC 0001 StepObject.message):

  • Text-only content is a string.
  • Multimodal content (v1.6+) is a ContentPart[].

Before and after (one Claude Code turn):

- {"source": "user",  "message": [{"type": "text", "text": "…"}, {"type": "text", "text": "Fix the failing test."}]}
+ {"source": "user",  "message": "…\nFix the failing test."}
  {"source": "agent", "message": "Done."}

Scope: atif_content_value joins all-text parts with "\n", as the Anthropic and OpenAI Responses paths already do.

Changed Unchanged
Messages API requests (Claude, Chat Completions) Anthropic and Responses paths (already strings)
Response fallbacks (assistant_message, choices, answer) Text and image parts, unsupported parts, observations

Why

  • Uses the spec's text-only form, so the same text has the same shape for every provider.
  • Lossless: the original parts stay in extra.llm_request and extra.llm_response.

Without it: string-only readers, such as the NeMo Helix SDK (message: str), reject the whole Claude trajectory at steps.0.message.

Compatibility:

  • Text-only step messages that were arrays are now strings.
  • An empty content array [] becomes "".

Validation

  • observability::atif: 108 passed. The new test fails without the fix.
  • just test-rust: 5,828 of 5,830 passed. The 2 failures are local only, as in fix: emit schema-valid ATIF content parts #1301.
  • pre-commit: passed.
  • Harbor validator: the export is valid.
  • Helix SDK: accepts the export. It rejected the same export before this change.
  • Not run: the binding suites (they pass the JSON through unchanged) and just docs (the docs change is one sentence).

Where should the reviewer start?

atif_content_value in crates/core/src/observability/atif.rs.

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

Summary by CodeRabbit

  • Updates
    • ATIF exports now combine text-only message content into a single string, with each text part separated by a newline. Content that includes non-text parts remains structured.
  • Documentation
    • Clarified how text-only message content is represented in ATIF exports.

Collapse step messages whose content parts are all text into one
newline-joined string, as Relay already does for Anthropic and OpenAI
Responses output and for OpenAI Responses input. The shared step-message
path still emitted text-only part arrays for Messages API requests, such
as Claude's text-block prompts, and for response fallbacks such as
assistant_message content. Image-bearing parts keep the schema-only
arrays, observation results are unchanged, and the original payload stays
in extra.llm_request and extra.llm_response.

Signed-off-by: Fernando Luo <[email protected]>
@fernandol-nvidia
fernandol-nvidia requested review from a team as code owners October 13, 2026 22:45
@copy-pr-bot

copy-pr-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@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: 5f7778e5-e808-4bfd-b5d3-1d3a3965bebc
📥 Commits

Reviewing files that changed from the base of the PR and between 0fdef69 and eb0f8e3.

📒 Files selected for processing: 3
  • crates/core/src/observability/atif.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; 11 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: 6
.agents/skills/contribute-docs/SKILL.md — configured
.agents/skills/review-doc-style/SKILL.md — configured
CONTRIBUTING.md — configured
.agents/skills/prepare-code-freeze/SKILL.md — configured
.agents/skills/maintain-observability/SKILL.md — configured
.agents/skills/draft-release-notes/SKILL.md — configured
📓 Path-based instructions: 12
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/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
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: **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/atif_tests.rs
  • crates/core/src/observability/atif.rs
Source excerpt: Search documentation source for references to the old version and update current-version install commands, package examples, and configuration examples to `` where appropriate: Review matches before changing th...

📄 CodeRabbit inference engine (.agents/skills/prepare-code-freeze/SKILL.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: 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/atif_tests.rs
  • crates/core/src/observability/atif.rs
Source excerpt: Preserve MDX front matter and the JSX SPDX comment.

📄 CodeRabbit inference engine (.agents/skills/draft-release-notes/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: 3
crates/core/src/observability/atif.rs: 1

532-545: Text-only flattening in atif_content_value looks correct.

canonicalize_atif_content_parts returns Some only when every part is a valid text or image part. When every part has a string text, the join branch runs and produces a string. An image part has no text field, so mixed arrays stay as arrays. An empty array joins to an empty string, which is a valid ATIF message. Values that cannot be canonicalized still fall back to stringification.

The \n separator matches the existing joins in anthropic_messages_content_message and openai_responses_output_message.

Observation content in the exporter should be unchanged, because the diff touches only atif_content_value. Verify this: the supplied test_exporter_canonicalizes_content_parts expects the observation result.content to stay an array, so that test should still pass if observation content does not use this function.

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

802-825: LGTM!

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

337-338: LGTM!

Walkthrough

ATIF export now joins canonicalized arrays of text-only content parts with newlines. Arrays containing non-text parts remain arrays, and unsupported values are still stringified. The regression test and documentation cover this output.

Changes

ATIF content export

Layer / File(s) Summary
Text-part export behavior
crates/core/src/observability/atif.rs, crates/core/tests/unit/atif_tests.rs, docs/configure-plugins/observability/atif.mdx
The exporter joins text-only content parts with newlines and preserves arrays that contain non-text parts. The test checks user and agent messages, including input part metadata, and verifies the ATIF v1.7 shape. The documentation describes the newline-separated output.

Priority: ➖ Normal

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to eb0f8

Text-only ATIF step messages are emitted as newline-joined strings while multimodal content remains arrays; no material merge risk is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title follows Conventional Commits format with the lowercase type "fix", uses a concise imperative summary, is 49 characters, and has no trailing period.
Description check Passed The description includes all required sections, completed contribution and duplication checks, implementation details, reviewer guidance, a valid related-issues keyword, and validation results.
Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)

  • 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.

@willkill07 willkill07 self-assigned this Oct 13, 2026
@willkill07 willkill07 added this to the 0.11 milestone Oct 13, 2026
@willkill07

Copy link
Copy Markdown
Member

/ok to test eb0f8e3

@github-actions

Copy link
Copy Markdown

@willkill07
willkill07 merged commit 2392088 into NVIDIA:main Oct 14, 2026
97 checks passed

This branch was previously deployed

1 inactive deployment
fern — eb0f8e37 Deployed Oct 14, 2026 by willkill07 via Clean up docs preview #5707
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