nemo_gym.rollouts.health.checks
nemo_gym.rollouts.health.checks
Artifact normalization and single-rollout health checks.
Module Contents
Functions
Data
API
Normalize canonical TrajectoryTurn records for structural checks.
Bind turn-only and turn-or-invocation references with shared indexes and resolutions.
Whether this model’s own last call, in time, failed.
Per model rather than across every captured call: a judge or auxiliary request landing after a failed policy call would otherwise read as the rollout recovering, and hide the failure.
Without timestamps a multi-call chain cannot be ordered — call_index is
the position in the merged trajectory list, so a producer-supplied retry
can precede the attempt it retried. Say nothing rather than call a
recovered rollout unhealthy.
A last call the upstream rejected because the context was full is the
model’s own end, scored like any other answer, once the model has answered
earlier in the same conversation (_same_conversation). A success in another
conversation on the same server, such as a user simulator’s or another
session’s, says nothing of whether this request fit. Before any answer the request never fit the deployment (a
prompt or output budget too large for it), which is a failure like any
other. An unordered chain of only failures has no answer and ended on one of
them, so it is flagged.
How the conversation a call continues opens: its instructions, system prompt, or first message.
Calls of one conversation share it; another conversation on the same model server, such as a user simulator’s, opens differently. A call whose request was not captured has none.
Whether any model’s own last call failed.
Exclude only explicit upstream context rejections, never inferred empty generations.
A failed model call that returned no finished response, so it has no usage to account for.
Covers HTTP error replies and calls cut by a cancellation or timeout. This does not mean
nothing was generated: the server may have spent tokens on a cut call, and a cut stream may
have delivered part of its output first. Gym cannot tell which from the capture (the first
streamed event can arrive before any token), so these calls are skipped rather than guessed
at; run.stats.model_call_errors.usage_unknown counts them. Whether the rollout recovered is
rollout_ended_on_failed_model_call’s question.
A failed call that did finish (it has a finish reason) keeps the token checks, as does a body capture could not parse, which is a capture defect rather than a failed call.
An upstream refusal on length, of either kind: the engine generated nothing, so the token checks have nothing
to read. Only an overflow (_is_context_overflow_rejection) can be the model’s own end.
Return usable model-call references from turns or invocations.
Group calls by the model they went to.
Whether a turn’s reasoning holds anything, Anthropic Messages thinking blocks included.
Kept out of _nonempty, which also decides whether a response is actionable, so that thinking never counts
as an answer there.
Whether a saved response holds something the agent can act on: answer text, a refusal or a tool call, in the Responses, Chat Completions or Messages shape. Reasoning alone, a summary of it included, is not usable.
Flag a model whose own last call in the rollout failed.
The bound-call checks cannot see this: binding resolves a reference by
(model_ref, response_id) or model_call_id, and a call that failed came
back with none of them, so it is absent from matched_calls no matter what
the producer claims. Reading the captured calls directly also covers the
agents that publish no trajectory at all.
Judged per model and in time order — see _chain_ended_on_failure. Only
the chain’s last call counts, so a failure the client retried successfully
stays healthy; the signal is that the rollout ENDED on a failure, which is
what makes its reward indistinguishable from a genuine zero. A last call
the upstream rejected as a context-length overflow is not flagged once the
model has answered earlier in the same conversation: that zero is the
model’s own result.
One finding per rollout, counting the tool outputs that open with a harness tool-failure marker.
A marker counts only from a tool that returns it (_TOOL_FAILURE_MARKERS), and a call recorded as completed
is not counted: a command that succeeded can print the same text, for example when it reads a log.
Whether two calls continue one conversation: their requests open the same way, and no captured session tells them apart. Two agents can share instructions, so a session only ever separates calls.
Whether a turn’s own model calls end on a context-overflow rejection that another check accounts for.
Each of the turn’s references must resolve to exactly one call: a call that another turn’s reference
resolved says nothing about this turn. Of the turn’s calls, the last in time decides, as in
_chain_ended_on_failure, so an overflow followed by an empty retry is still hollow. When the calls
cannot be ordered, every one must be an overflow.
Each such overflow must be accounted for: by a success of the same model in the same conversation, or by
rollout_ended_on_failed_model_call flagging that model’s chain. An unordered chain that mixes in another
conversation’s success is flagged by neither, so its empty turn stays hollow.
Normalize and validate check IDs supplied by library, CLI, or Hydra config.