Expand description
Grok CLI (Grok Build): ~/.grok/sessions/<urlencoded-cwd>/<session-uuid>/.
A Grok session is a directory of files, three of which matter here:
chat_history.jsonl— the model-protocol log, one record per line typed bytype:system,user,assistant(text +tool_calls),reasoning(summary +encrypted_content),tool_result. This is what the model sees on continuation.updates.jsonl— the ACP display log (session/updatenotifications:user_message_chunk,agent_message_chunk,agent_thought_chunk,tool_call,tool_call_update,turn_completed, …). This is whatgrok --resumeandgrok exportactually replay; a session without it is invisible to Grok.summary.json— session metadata (id, cwd, title, model, git info).
The remaining sidecars (events.jsonl telemetry, signals.json,
prompt_context.json, resources_state.json, rewind_points.jsonl,
system_prompt.txt) are carried verbatim in the GrokSession body so a
native load → save round-trips them; from_common leaves them empty and
Grok regenerates what it needs.
to_common reads the conversation from chat_history.jsonl and backfills
what that log lacks from updates.jsonl: per-message timestamps, tool-result
error status, and per-turn stop reasons. from_common regenerates
chat_history.jsonl, updates.jsonl, and summary.json.
User images follow Grok’s own split: the display log carries the bytes
(an ACP {"type": "image", data, mimeType} chunk of the prompt), while
the model log holds only text — natively a Grok-generated description;
from_common writes an [image] placeholder there.
from_common cannot preserve per-turn usage, non-turn stop reasons,
reasoning signatures, structured tool-result JSON, reasoning record ids, or
system prompt records.
Structs§
- Assistant
Line - An
assistantline: response text plus anytool_calls(whoseargumentsare JSON-in-a-string). - Grok
- The Grok CLI harness marker.
- Grok
Session - Faithful in-memory representation of one Grok session directory.
- Grok
Store - Reads and writes Grok session directories under a sessions root (default
~/.grok/sessions, or$GROK_HOME/sessions). - Reasoning
Line - A
reasoningline: summary text plus the opaque provider reasoning token. - System
Line - A
systemline: the injected system prompt. - Tool
Result Line - A
tool_resultline. - User
Line - A
userline: content blocks, plusprior_turn_interruptwhen the previous turn was aborted mid-flight.
Enums§
- Chat
Record - One
chat_history.jsonlline. Known kinds are typed; anything else (or a malformed known kind) is kept whole inChatRecord::Other.