Files
trinity-rl/envs/nemotron_tool_calling/README.md
T
carstenandClaude Opus 5.5 609e832572 Move to current prime-rl, verifiers and renderers; DeepSeek V4.1 support
Bump prime-rl to trinity-dsv41: upstream main, PR #4057 (DeepSeek V4.1
Flash) with the engram port onto the shared n-gram module, and renderers
tracking its trinity-dsv41 branch (v0.2.0 + the Hermes parser).

Port the envs to the current verifiers v1 API, rl.toml to the new config
schema (IPO loss kept as the new default), and bootstrap/launch/prepare
scripts to the new layout.

Decensor now runs DecensorEnv: the simulated user writes reviewed
follow-ups up to each row's target_turns and every assistant turn is
judged. Earlier runs trained on the first turn only.
tests/test_multiturn_env.py drives the full loop against a mock endpoint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 14:39:44 +00:00

4.1 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" }

The runtime is set on the agent, not the harness; verifiers' default runtime is a Prime sandbox, which this in-process harness does not need.

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

The text-level hermes parser comes from the renderers fork in prime-rl/deps/renderers (dphn/renderers@trinity-dsv41). Select tool_parser = "hermes", reasoning_parser = "think" in the orchestrator renderer.

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.

Restart existing environment workers after upgrading so they import the updated package and renderer.

Validated runtime: verifiers 72d08a0b6 (0.4.2.dev) with the renderers in prime-rl/deps/renderers. (Previously: PRIME-RL 31ff561, verifiers b13ba60, renderers bdb96b0 + Hermes parser.) 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.