Files
trinity-rl/envs/nemotron_tool_calling/README.md
T
carsten 84d7fe4166 Trinity-Mini RL: envs, production recipe, and run scripts
Migrated from the rl-toolkit snapshot deployed for the 2026-09-15 production
run (toolkit e191cf1 plus uncommitted changes). PRIME-RL is now a submodule on
dphn/prime-rl@trinity; the v0 envs, parity tests, OPD experiment, and old
configs are not carried over.
2026-10-14 12:39:23 +00:00

4.2 KiB

Native Nemotron tool calling

This package trains native next-action prediction, not execution of a live tool backend. Its bundled NativeToolCallingHarness sends the row's schemas in the OpenAI tools field through verifiers' interception endpoint and returns after exactly one assistant response. Historical tool calls and results remain typed messages in the initial conversation. No new tool is dispatched or simulated.

The package exports both the taskset and its default harness. Explicit config:

[env.taskset]
id = "nemotron-tool-calling-v1"
dataset = "all"
exclude_message_actions = true

[env.agent.harness]
id = "nemotron-tool-calling-v1"
runtime = { type = "subprocess" }

An unset harness resolves to this package's bundled harness. Do not override it with null or use a max_turns budget to implement single-action completion. Normal completion is agent_completed; token-budget exhaustion still receives the existing truncation penalty.

Reward contract

  • dataset = "all" selects tool_use_pivot and function_calling.
  • Only structured assistant tool_calls can earn task reward. Fenced JSON, raw JSON in content, XML-like text, compact call strings, and reasoning examples are never scraped. There is no text fallback switch.
  • The pivot scorer requires exactly one call with the reference name and exact recursive arguments. Extra calls, wrong argument types, unknown tool names, invalid JSON, non-object arguments, duplicate JSON keys, and non-finite constants receive zero task reward.
  • Message/no-call targets are always excluded. exclude_message_actions=false is rejected during config validation.
  • Workplace and indirect-prompt-injection remain explicit proxy selectors, not live tool environments. They also require valid native calls to advertised tools; they cannot earn reward through prose or abstaining from all calls.
  • The final reward remains task_reward * anti_hacking_multiplier. The Gemma judges provide the existing guard penalties, not tool execution or success.

emitted_tool_call measures native field presence. valid_native_tool_calls requires a nonempty action set with valid JSON-object arguments. Neither metric claims that a tool executed. tool_call_shape remains a diagnostic, not reward.

Trinity parser

Apply patches/submodules/renderers-hermes-tool-parser.patch to the runtime's deps/renderers, and select tool_parser = "hermes", reasoning_parser = "think" in the orchestrator renderer. The patch installs renderers/hermes.py, registers it, and wires the default renderer's reasoning-prefill detection.

The parser ignores explicit/prefilled reasoning and Markdown code examples, requires strict JSON envelopes with object arguments, and preserves text before, between, and after calls. Parse-error spans refer to the original completion tokens. Envelopes inside JSON string arguments do not prematurely end a call.

The patch is a full patch against unmodified upstream renderers, not an incremental patch on top of the old Hermes patch. When upgrading an existing deployment, reverse its previous Hermes patch before applying this version; preserve unrelated dependency edits. Restart existing environment workers so they import the updated package and renderer.

Validated runtime: PRIME-RL 31ff561, verifiers b13ba60, renderers bdb96b0 + Hermes parser (dphn/renderers@trinity). The native environment is version 0.2.0; it intentionally changes the old text-fallback reward and unknown-tool-continuation behavior.

Regression checks

From prime-rl/, in the runtime venv with this package and the shared guard installed:

uv run --with pytest --with pytest-asyncio python -m pytest \
  ../envs/nemotron_tool_calling/tests \
  deps/renderers/tests/test_hermes.py

The checks cover native-only scoring, strict argument validation, parser cases using Trinity's pinned real tokenizer, and full verifiers interception with both the eval and training clients. Test providers run locally with scripted outputs; the training-path checks verify native schema rendering, original completion token IDs/log-probabilities, one sampled turn, and no fabricated tool responses. They do not require GPUs, contact a paid model API, or establish model quality.