Skip to main content

Module grok

Module grok 

Source
Expand description

Grok CLI transcripts — ~/.grok/sessions/<percent-encoded cwd>/<session uuid>/chat_history.jsonl.

Two things about the layout. The first directory level is the working directory the session ran in, percent-encoded (%2Fopt%2Frecall-echo), so discovery decodes it rather than reporting a mangled path. The second is that each session directory also holds prompt_history.jsonl, which contains only the human’s prompts — tempting, and wrong: a conversation with the model’s side missing is not a conversation.

§Shapes

{"type":"system",     "content":"<string>"}                    harness
{"type":"user",       "content":[{"type":"text","text":"…"}]}  array!
{"type":"assistant",  "content":"OK", "tool_calls":[…]}        string!
{"type":"reasoning",  "summary":[{"type":"summary_text",…}]}   private
{"type":"tool_result","content":"exit: 0\n…"}

content is an array on user turns and a bare string on assistant turns — in the same file. reasoning is the model’s private thinking; recording it would put unasserted thoughts into memory as though the model had said them, the same hazard the Claude Code parser avoids by dropping thinking blocks.

§Which user turns are real

Grok injects context under type: "user": a <user_info> preamble, project instructions, skill and MCP reminders. It marks them — injected records carry synthetic_reason, and a real prompt carries prompt_index — so the rule is: when a file marks any prompt with prompt_index, only those are turns; when none does, everything without a synthetic_reason is. The prompt itself arrives wrapped in <user_query>, which is framing for the model and is unwrapped.

Structs§

GrokTranscripts
Grok’s session records.