# tinker_cookbook.rl.EnvFromMessageEnv ## *class* [**tinker_cookbook.rl.EnvFromMessageEnv**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/message_env.py#L84)(*types.[Env](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/rl/env/index.md)*) 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**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/message_env.py#L172)(*action*, *extra*) Parse tokens to a message, delegate to MessageEnv, and render response. **Parameters:** - [**action**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/message_env.py#L173) (*types.Action*) - [**extra**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/message_env.py#L173) (*types.[ActionExtra](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/rl/actionextra/index.md) | None*) **Returns:** *types.[StepResult](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/rl/stepresult/index.md)* ### [**set_parse_error_policy**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/message_env.py#L284)(*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`](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/rl/messageenv/index.md) when it supports one (content failures — unparsable tool calls — are handled there). **Parameters:** - [**policy**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/message_env.py#L284) (*ParseErrorPolicy*) **Returns:** *None* ### [**inject_messages**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/message_env.py#L343)(*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:** - [**messages**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/message_env.py#L344) (*list\[[Message](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/renderers/message/index.md)\]*) **Returns:** *tuple\[tinker.[ModelInput](https://tinker-docs.thinkingmachines.ai/tinker/api-reference/types/modelinput/index.md), StopCondition\]* **Raises:** - TypeError: If the inner :class:`MessageEnv` does not support - message injection. ### [**set_max_tool_calls**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/message_env.py#L365)(*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**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/rl/message_env.py#L365) (*int*) **Returns:** *None* ## Referenced by - [tinker_cookbook.rl.MessageEnv.observe_truncated_response](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/rl/messageenv/#messageenv-observe_truncated_response)