Skip to navigation

nemo_gym.agents.context_management.controller

View as MarkdownOpen in Claude

Rewrite-boundary controllers and context-admission guards.

Module Contents

Classes

NameDescription
HistoryControllerRetry-safe per-rollout owner of request-view rewrite boundaries.
TurnChunkedHistoryControllerFreeze one compacted base and append a tail for up to K actions.

Functions

NameDescription
build_guard_outcome_records-
evaluate_context_guardsEvaluate every configured hard limit without changing history state.
pending_observation_group_ids-

API

class nemo_gym.agents.context_management.controller.HistoryController(
history: 'SemanticHistory',
policy: 'HistoryPolicy'
)

Retry-safe per-rollout owner of request-view rewrite boundaries.

_boundary_events
list[RewriteBoundaryEvent] = []
_completed_descriptor
tuple[str, ...] | None = None
_completed_image_part_ids
tuple[str, ...] | None = None
_completed_items
tuple | None = None
_completed_view_digest
str | None = None
_context_epoch
= 0
_pending_boundary
RewriteBoundaryEvent | None = None
boundary_events
tuple[RewriteBoundaryEvent, ...]
evaluation_count
= 0
pending_boundary
RewriteBoundaryEvent | None
nemo_gym.agents.context_management.controller.HistoryController._make_boundary(
applies_to_step: int,
previous_view_digest: str,
current_view_digest: str
nemo_gym.agents.context_management.controller.HistoryController._plan(
applies_to_step: int
nemo_gym.agents.context_management.controller.HistoryController.acknowledge(
) -> None
nemo_gym.agents.context_management.controller.HistoryController.prepare(
applies_to_step: int
class nemo_gym.agents.context_management.controller.TurnChunkedHistoryController(
history: 'SemanticHistory',
policy: 'HistoryPolicy',
actions_per_chunk: int
)

Bases: HistoryController

Freeze one compacted base and append a tail for up to K actions.

_action_ids
list[str] = []
_action_turns
list[int] = []
_base_plan
HistoryViewPlan | None = None
_block_index
= -1
_chunk_id
str | None = None
_chunk_records
list[FinalizedChunkRecord] = []
_completion_ids
list[str] = []
_known_base_part_ids
frozenset[str] = frozenset()
_last_acknowledged
PreparedHistoryView | None = None
chunk_records
tuple[FinalizedChunkRecord, ...]
completed_actions_in_current_chunk
int
current_chunk_id
str | None
schedule_config_digest
schedule_name
= 'turn_chunked_recency'
schedule_version
= '1'
nemo_gym.agents.context_management.controller.TurnChunkedHistoryController._finalize_chunk(
early_close_reason: str | None
) -> None
nemo_gym.agents.context_management.controller.TurnChunkedHistoryController._make_boundary(
applies_to_step: int,
previous_view_digest: str,
current_view_digest: str
nemo_gym.agents.context_management.controller.TurnChunkedHistoryController._plan(
applies_to_step: int
nemo_gym.agents.context_management.controller.TurnChunkedHistoryController._start_chunk(
applies_to_step: int
) -> None
nemo_gym.agents.context_management.controller.TurnChunkedHistoryController.acknowledge_action(
action_id: str,
completion_id: str
) -> None
nemo_gym.agents.context_management.controller.TurnChunkedHistoryController.close_for_guard(
guard_name: str
) -> bool

Close a non-empty chunk before its next action and allow recompaction.

nemo_gym.agents.context_management.controller.TurnChunkedHistoryController.finalize_terminal() -> None
nemo_gym.agents.context_management.controller.build_guard_outcome_records(
rollout_id: str,
chunk_id: str | None,
applies_to_step: int,
completed_action_count: int,
pending_group_ids: typing.Sequence[str],
early_chunk_close: bool

Evaluate every configured hard limit without changing history state.

nemo_gym.agents.context_management.controller.pending_observation_group_ids(
applies_to_step: int
) -> tuple[str, ...]