Skip to content

Support Anthropic message format as data input #1341

Description

@cwing-nvidia

Use cases, pain points, and background

Follow-up to #1339. Users with datasets in Anthropic format also need conversion.

Anthropic has structural differences from both Chat Completions and the Responses API:

  • Top-level system field (string) instead of a system message in the messages array
  • Tool calls are content blocks with type: "tool_use" inside assistant messages, not a separate tool_calls array
  • Tool results are content blocks with type: "tool_result" inside user messages, not separate role: "tool" messages
  • A single message can mix text and tool_use/tool_result blocks in the same content array

Description

Extend convert_to_gym_format() in prompt.py to handle Anthropic-format data (text-only and with tool calls).

Acceptance Criteria

  • A user can call convert_to_gym_format(row) on a dict with Anthropic-style messages (text-only) and get back a valid Gym row
  • A user can call convert_to_gym_format(row) on a dict with Anthropic tool_use/tool_result blocks and get back a valid Gym row
  • Mixed-content messages (text + tool blocks) are handled correctly
  • Unit tests cover single and multi-turn Anthropic conversations with and without tool calls

Parent issue: #1338

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions