EnvFromMessageEnv - Tinker Documentation
tinker_cookbook.rl.EnvFromMessageEnv
class tinker_cookbook.rl.EnvFromMessageEnv( types. Env)
Adapter that wraps a MessageEnv to implement the token-level Env interface.
This bridges the message-level abstraction to the token-level interface expected by the RL training loop.
step( action, extra)
Parse tokens to a message, delegate to MessageEnv, and render response.
Parameters:
- action ( types.Action)
- extra ( types. ActionExtra | None)
Returns: types. StepResult
set_parse_error_policy( policy)
Apply a rollout-level parse-error policy (seam used by the rollout runner: the narrow method interface through which it pushes configuration into the env).
Configures this adapter's structural-failure handling and forwards the policy to the inner MessageEnv when it supports one (content failures — unparsable tool calls — are handled there).
Parameters:
- policy ( ParseErrorPolicy)
Returns: None
inject_messages( messages)
Inject externally supplied messages before the next sampling call.
Seam used by rollout hooks (on_turn_begin). Forwards to the inner MessageEnv.add_messages and re-renders the conversation, so injected tokens count toward any trajectory budget.
Parameters:
Returns: tuple[tinker. ModelInput, StopCondition]
Raises:
- TypeError: If the inner :class:
MessageEnvdoes not support message injection.
set_max_tool_calls( max_tool_calls)
Forward a rollout-level tool-call limit to the inner MessageEnv.
Seam used by the rollout runner for RolloutLimits.max_tool_calls (tool dispatch happens inside the message env, so the runner cannot enforce it directly). Logs a warning when the inner env does not support a tool-call limit, in which case the limit is not enforced.
Parameters:
- max_tool_calls ( int)
Returns: None