Skip to content

feat(trajectory): export image content parts to ATIF instead of failing the export #5871

Open

Description

@yaoyu-33

Problem

Gym's ATIF exporters keep text only. A transcript that contains an image part cannot be exported:

  • transcript_to_atif() (nemo_gym/trajectory/atif_export.py) raises AtifExportError: ... only text content parts are supported for an input_image part in a message or a tool output. The Harbor Environment Server uses it to write /logs/agent/trajectory.json for the verifier, and masks the turn as harbor:trajectory_export_failed instead of grading it.
  • export_rollouts_to_atif() builds ATIF rollout artifacts from ng_trajectory. It also accepts only text parts, and it rejects a user turn after agent output (later system or user turns are not supported). One such rollout fails the run's ATIF export.

Images are becoming a normal part of agent transcripts:

Reproduction

from nemo_gym.trajectory.atif_export import transcript_to_atif

transcript_to_atif(
    [{"role": "user", "content": "Describe the image after rotating it."}],
    [
        {"type": "function_call", "call_id": "c1", "name": "rotate", "arguments": "{}", "id": "fc1", "status": "completed"},
        {"type": "function_call_output", "call_id": "c1", "output": "{\"ok\":true}"},
        {"type": "message", "role": "user", "content": [
            {"type": "input_image", "image_url": "data:image/png;base64,iVBORw0KGgo=", "detail": "auto"}]},
        {"type": "message", "role": "assistant", "id": "m1", "status": "completed",
         "content": [{"type": "output_text", "text": "A cat.", "annotations": []}]},
    ],
    session_id="s", agent_name="a", agent_version="0",
)
# AtifExportError: transcript[2].content[0]: only text content parts are supported

Without the image message the same transcript exports.

Proposal

ATIF v1.7 already represents images: a content part {"type": "image", "source": {"media_type": ..., "path": ...}}, which Gym models as AtifContentPart / AtifImageSource in nemo_gym/trajectory/atif_v1_7.py.

  1. Decode each input_image data URI (MediaFile.from_data_uri, feat: binary sandbox files and shared media helpers #4917) and write it next to the trajectory file under a content-named path, such as images/<sha256>.<ext>. Emit an ATIF image part that points to it.
  2. Map a user turn after agent output that carries only images (the simple_agent tool-image message) to an observation of the preceding step, as _attach_user_observation already does for text.
  3. Keep refusing what ATIF cannot represent, such as remote image URLs and file IDs, so a converter gap is never graded.
  4. For the Harbor Environment Server, upload the image files to /logs/agent/ beside trajectory.json, so a verifier that reads the transcript can open them.

Acceptance

  • The reproduction exports, with the image file written and referenced by path.
  • A Harbor turn whose transcript holds a tool image is graded, not masked.
  • ATIF rollout artifacts export simple_agent rollouts with tool images.
  • Text-only transcripts export byte-for-byte as before.

Related: #5719, #5868 (harness guide "Support images" section).

🤖 Generated with Claude Code

Activity

  1. added
    feature
    area:core
    on Nov 9, 2026
  2. changed the title [-]ATIF export drops support for image content parts; transcripts with images are masked or fail export[/-] [+]feat(trajectory): export image content parts to ATIF instead of failing the export[/+] on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platformarea:corefeature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions