# The `.chat` format A chat session on disk. JSON Lines with one non-JSON line on top, so a reader that only knows JSON skips it as a comment while the file still announces what it is when opened in anything. Sessions live in `user://.claude-godot/sessions/.chat`, outside the project so they are never committed with the game. They are written as the conversation happens, not on an explicit save. ``` # CHAT: v1.0 {"type":"session","session_id":"2026-09-12T16-30-00","title":"Ant rig previews", …} {"type":"message","index":0,"message":{"role":"user","content":[…]}} {"type":"message","index":1,"message":{"role":"assistant", …}} {"type":"reasoning","after_message":1,"text":"The user wants …"} ``` ## The marker ``` # CHAT: v ``` The first line, and the only source of the format version. Bumped when the shape changes in a way a reader must notice. A reader that meets a line type it doesn't recognise skips it rather than failing, so a file from a later version still opens for the parts it knows. ## `session` One header line. Describes the conversation and how to resume it. | Field | | |---|---| | `session_id` | Matches the filename | | `title`, `objective`, `keywords` | Set by the model via `update_session_description`; empty until it names the session | | `provider`, `provider_label`, `protocol`, `endpoint`, `model` | What produced this conversation | | `system_prompt` | The prompt in force | | `max_steps_per_turn` | The cap that was in effect | | `total_input_tokens`, `total_output_tokens` | Usage so far | | `total_cost`, `total_cached_tokens`, `total_reasoning_tokens` | What the provider reported; `total_cost` stays 0 where none does | `protocol` matters on resume. The message lines are in the **provider's own wire format**, so a session is tied to the protocol that recorded it — reopening one switches the dock back to its provider and model rather than feeding Responses API items to an Anthropic endpoint. ## `message` One per message, carrying `index` and the message *exactly as it goes to the provider*. No re-rendering, no normalising: this is the real context, which is why the shapes differ between files. - **Responses API** — `input_text`/`input_image` parts, `reasoning` items, `function_call`, `function_call_output`. - **Chat Completions** — `role` of user/assistant/tool, `tool_calls`, `image_url` parts holding data URIs. - **Anthropic** — content blocks: `text`, `thinking`, `tool_use`, `tool_result`, `image`. Everything in the turn is here, tool calls and results included. Images are the base64 the model was actually given, which is faithful but is also why a session with screenshots in it gets large. API keys are never in a session file. They travel in an HTTP header, not in the conversation. ## `reasoning` The model's commentary, with `after_message` recording which message it followed so the ordering survives. This line type exists because of one protocol. The Responses API and Anthropic both keep thinking in their wire history, so it is already in the `message` lines for those. Chat Completions does not, and it must not be added — DeepSeek documents `reasoning_content` as not for resubmission, and the history is replayed to the provider on every turn. Writing it separately keeps the transcript complete without corrupting what gets sent. ## Resuming Reading the lines back. `message` lines restore the provider's history verbatim, `reasoning` lines are kept so re-saving doesn't drop them, and the header restores the title, token counters, provider and model.