# tinker_cookbook.renderers.RenderContext ## *class* [**tinker_cookbook.renderers.RenderContext**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/renderers/base.py#L682)() Context passed to render_message for rendering a single message. This allows renderers to access information about the message's position in the conversation without changing the render_message signature for each new piece of context needed. **Fields:** - [**idx**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/renderers/base.py#L691) (*int*) – Index of the message in the conversation (0-based). - [**is_last**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/renderers/base.py#L694) (*bool*) – Whether this is the last message in the conversation. - [**prev_message**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/renderers/base.py#L697) (*[Message](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/renderers/message/index.md) | None*, default: `None`) – The previous message in the conversation, if any. - [**next_message**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/renderers/base.py#L700) (*[Message](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/renderers/message/index.md) | None*, default: `None`) – The next message in the conversation, if any. Used by renderers whose templates look ahead — e.g. Qwen3.5-family tool-response grouping closes the shared user block only after the final consecutive tool message. None for the last message or when a message is rendered standalone. - [**last_user_index**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/renderers/base.py#L708) (*int*, default: `-1`) – Index of the last user message in the conversation. -1 if no user messages. This is computed by the base build_generation_prompt/build_supervised_example and used by renderers like Qwen3.5 that need to treat assistant messages differently based on whether they come before or after the last user message. - [**in_last_assistant_turn**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/renderers/base.py#L716) (*bool*, default: `False`) – Whether this message belongs to the turn the model is being asked to produce. Distinct from `is_last`, which is literally the final message. A turn can span several messages -- an assistant message, a tool response, the assistant's follow-up -- so a renderer that keeps reasoning in the produced turn while stripping it from history has to ask about the turn, not the message. `_last_assistant_turn_start_index` says where it starts. ## Referenced by - [tinker_cookbook.renderers.Renderer.render_message](https://tinker-docs.thinkingmachines.ai/cookbook/api-reference/renderers/renderer/#renderer-render_message)