tinker_cookbook.rl.MessageEnv
class tinker_cookbook.rl.MessageEnv(ABC)
Abstract base class for message-level environments.
initial_observation()
Return the initial conversation history as renderer messages.
Returns: list[Message]
Abstract method.
step(message)
Process an assistant message and return reward/next state.
Parameters:
Returns: MessageStepResult
Abstract method.
observe_truncated_response(message)
Record a truncated assistant response without running a full step.
Used by the continue-past-truncation path (the sampler hit the
per-turn max_tokens cap, stop_reason == "length", and
EnvFromMessageEnv has terminate_on_length=False): the
truncated message is appended to
the conversation as-is (no tool execution, no completion check) so the
rollout can continue on the next turn.
Parameters:
Returns: list[Message] | None: The updated message history, or None if this environment does not support recording truncated responses (the default), in which case the caller falls back to the default terminate-on-length behavior.
add_messages(messages)
Append externally injected messages to the conversation.
Used by rollout hooks (on_turn_begin) to inject messages before a
sampling call.
Parameters:
Returns: list[Message] | None: The updated message history, or None if this environment does not support message injection (the default).