Skip to navigation

nemo_gym.trajectory.trajectory_format

View as Markdown

Versioned trajectory wire formats and their deliberately lossy v1 projection.

Module Contents

Functions

NameDescription
_legacy_interval_preserved-
_project_gaps_v1-
_restore_native_tool_idsRestore v1’s native request namespace only with an explicit, collision-free mapping.
canonical_tool_recordKeep canonical timing separate from the old flat compatibility projection.
project_bundle_v1Return the unversioned observation envelope accepted by existing readers.
project_observation_v1Project only qualified intervals, keeping unknown values unknown.
project_result_v1Export both retained envelopes with one atomic, conservative identity decision.
project_trajectory_v1Return v1, losing attempt, instance, parent, failure and detailed timing provenance.
reject_v2_fieldsDo not silently discard meaningful v2 evidence mislabeled as a v1 wire record.
validate_failure_eventsValidate the shared serialized failure-event map without constructing exceptions.

Data

_TOOL_FLAT_FIELDS

_TOOL_V2_FIELDS

_V2_ONLY_GAPS

API

nemo_gym.trajectory.trajectory_format._legacy_interval_preserved(
gap: dict[str, typing.Any],
tools: list[dict[str, typing.Any]]
) -> bool
nemo_gym.trajectory.trajectory_format._project_gaps_v1(
gaps: list[dict[str, typing.Any]],
tools: list[dict[str, typing.Any]]
) -> list[dict[str, typing.Any]]
nemo_gym.trajectory.trajectory_format._restore_native_tool_ids(
tool_groups: list[list[dict[str, typing.Any]]],
invocations: list[dict[str, typing.Any]],
turns: list[dict[str, typing.Any]],
compactions: list[dict[str, typing.Any]],
gaps: list[dict[str, typing.Any]],
model_calls: list[dict[str, typing.Any]]
) -> None

Restore v1’s native request namespace only with an explicit, collision-free mapping.

Model-call payloads and text are independent evidence and are never rewritten. All reference values are collected before any edit so chained mappings cannot cascade.

nemo_gym.trajectory.trajectory_format.canonical_tool_record(
record: dict[str, typing.Any],
include_join_evidence: bool
) -> dict[str, typing.Any]

Keep canonical timing separate from the old flat compatibility projection.

nemo_gym.trajectory.trajectory_format.project_bundle_v1(
bundle: dict[str, typing.Any],
restore_native_ids: bool = True
) -> dict[str, typing.Any]

Return the unversioned observation envelope accepted by existing readers.

nemo_gym.trajectory.trajectory_format.project_observation_v1(
record: dict[str, typing.Any]
) -> dict[str, typing.Any]

Project only qualified intervals, keeping unknown values unknown.

nemo_gym.trajectory.trajectory_format.project_result_v1(
trajectory: dict[str, typing.Any],
bundle: dict[str, typing.Any] | None
) -> tuple[dict[str, typing.Any], dict[str, typing.Any] | None]

Export both retained envelopes with one atomic, conservative identity decision.

nemo_gym.trajectory.trajectory_format.project_trajectory_v1(
trajectory: dict[str, typing.Any],
restore_native_ids: bool = True
) -> dict[str, typing.Any]

Return v1, losing attempt, instance, parent, failure and detailed timing provenance.

This does not establish that v1 consumers can represent retries: consumers that need those identities must migrate to v2. No endpoints or durations are manufactured.

nemo_gym.trajectory.trajectory_format.reject_v2_fields(
records: object
) -> None

Do not silently discard meaningful v2 evidence mislabeled as a v1 wire record.

nemo_gym.trajectory.trajectory_format.validate_failure_events(
events: dict[str, dict[str, typing.Any]]
) -> None

Validate the shared serialized failure-event map without constructing exceptions.

nemo_gym.trajectory.trajectory_format._TOOL_FLAT_FIELDS = {'started_at', 'completed_at', 'duration_ms', 'timing_source'}
nemo_gym.trajectory.trajectory_format._TOOL_V2_FIELDS = {'agent_instance', 'span_id', 'native_tool_call_id', 'parent_span_id', 'model_ca...
nemo_gym.trajectory.trajectory_format._V2_ONLY_GAPS = frozenset({'tool_attempt_identity_unavailable', 'tool_agent_instance_unavailable...