Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

sessions: Grok Build's tool calls and skills are counted (MaxMooreMy on X)

yetone7e58591dcf4b
diff --git a/internal/sessions/codex.go b/internal/sessions/codex.go
index d6579ce3a..2d81325ad 100644
--- a/internal/sessions/codex.go
+++ b/internal/sessions/codex.go
@@ -198,6 +198,13 @@ func cxSkillReads(b []byte, name string) []string {
if strings.Contains(text, "*** Begin Patch") {
return nil
}
+ return skillReadsIn(text)
+}
+
+// skillReadsIn are the skills a command or a path that reads files calls
+// up: each SKILL.md read by its folder's name, once. A redirect into one
+// and a bare SKILL.md with no folder (a find -name, a grep) call none up.
+func skillReadsIn(text string) []string {
var out []string
for rest := text; ; {
i := strings.Index(rest, "SKILL.md")
diff --git a/internal/sessions/grok.go b/internal/sessions/grok.go
index fae817814..e3ae5161a 100644
--- a/internal/sessions/grok.go
+++ b/internal/sessions/grok.go
@@ -6,9 +6,13 @@ import (
"encoding/json"
"os"
"path/filepath"
+ "regexp"
"strconv"
"strings"
"time"
+ "unicode"
+
+ "github.com/tidwall/gjson"
"github.com/yetone/magpie/internal/appdir"
)
@@ -28,6 +32,17 @@ import (
// session it ran in, once. A fork starts with a copy of its source's
// updates, counted where they were first written: only those from the time
// it was made on count in it. `grok --resume <id>` picks one up again.
+//
+// A "tool_call" update is a call of a tool, written once a call (the
+// "tool_call_update"s after it are its progress), its name in
+// _meta["x.ai/tool"].name. Grok Build has no tool for skills: its prompt
+// lists each skill's SKILL.md by its path, and the model calls one up by
+// reading that file (read_file, or a command run_terminal_command runs),
+// as Codex's does. The user calls one up by typing /<name>: the prompt goes
+// in the updates as typed, and the skill's text is put in it only in
+// chat_history.jsonl, so a /<name> prompt counts as that skill when a
+// skill or command of that name is in one of the folders Grok Build finds
+// them in. Its own commands (/compact) are marked hostTurn.
// GrokDir is Grok Build's folder: $GROK_HOME, else ~/.grok.
func GrokDir() string {
@@ -140,6 +155,9 @@ type grokLine struct {
Type string `json:"type"`
Text string `json:"text"`
} `json:"content"`
+ Meta struct {
+ HostTurn bool `json:"hostTurn"`
+ } `json:"_meta"`
Usage *struct {
grokUsage
ModelUsage map[string]grokUsage `json:"modelUsage"`
@@ -151,6 +169,7 @@ type grokLine struct {
var (
grokTurn = []byte(`"turn_completed"`)
grokUser = []byte(`"user_message_chunk"`)
+ grokCall = []byte(`"sessionUpdate":"tool_call"`)
grokHook = []byte(`"sessionUpdate":"hook_execution"`)
)
@@ -237,12 +256,17 @@ func grokUpdate(s *state, c *grokCarry, b []byte, main bool) {
return
}
s.saw(at, main)
- user := main && c.Title == "" && bytes.Contains(b, grokUser)
+ prompt := main && bytes.Contains(b, grokUser)
+ user := prompt && c.Title == ""
if !user && c.InPrompt {
// the first prompt's chunks are over
c.Title, c.Prompt, c.InPrompt = title(c.Prompt), "", false
}
- if !user && !bytes.Contains(b, grokTurn) {
+ if bytes.Contains(b, grokCall) {
+ grokTool(s, at, b)
+ return
+ }
+ if !prompt && !bytes.Contains(b, grokTurn) {
return
}
var l grokLine
@@ -252,10 +276,16 @@ func grokUpdate(s *state, c *grokCarry, b []byte, main bool) {
u := l.Params.Update
switch u.SessionUpdate {
case "user_message_chunk":
- if user && u.Content.Type == "text" {
+ if u.Content.Type != "text" {
+ return
+ }
+ if user {
c.Prompt += u.Content.Text
c.InPrompt = true
}
+ if !u.Meta.HostTurn {
+ s.tool(at, "", grokSlashSkill(s.Cwd, u.Content.Text))
+ }
case "turn_completed":
if u.Usage == nil {
return
@@ -271,6 +301,78 @@ func grokUpdate(s *state, c *grokCarry, b []byte, main bool) {
}
}
+// grokTool counts a "tool_call" update: the tool, and each skill it calls
+// up by reading its SKILL.md.
+func grokTool(s *state, at time.Time, b []byte) {
+ u := gjson.GetBytes(b, "params.update")
+ if u.Get("sessionUpdate").String() != "tool_call" {
+ return
+ }
+ name := cmp.Or(u.Get(`_meta.x\.ai/tool.name`).String(), u.Get("title").String())
+ if name == "" {
+ return
+ }
+ var text string
+ switch name {
+ case "read_file":
+ text = cmp.Or(u.Get("rawInput.target_file").String(), u.Get("rawInput.path").String())
+ case "run_terminal_command":
+ text = u.Get("rawInput.command").String()
+ }
+ s.tool(at, name, "")
+ if strings.Contains(text, "SKILL.md") {
+ for _, k := range skillReadsIn(text) {
+ s.tool(at, "", k)
+ }
+ }
+}
+
+// grokSkillName is a name a /<name> prompt can call a skill up by.
+var grokSkillName = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9_.-]*$`)
+
+// grokSlashSkill is the skill a prompt typed as /<name> calls up, "" when
+// it calls up none: no skill or command of that name is in a folder Grok
+// Build finds them in, from the session's folder up and in the user's.
+func grokSlashSkill(cwd, text string) string {
+ rest, ok := strings.CutPrefix(text, "/")
+ if !ok {
+ return ""
+ }
+ name := rest
+ if i := strings.IndexFunc(rest, unicode.IsSpace); i >= 0 {
+ name = rest[:i]
+ }
+ if !grokSkillName.MatchString(name) || strings.Contains(name, "..") {
+ return ""
+ }
+ var bases []string
+ home, _ := os.UserHomeDir()
+ roots := []string{home}
+ for d := filepath.Clean(cwd); cwd != "" && filepath.IsAbs(d); {
+ roots = append(roots, d)
+ up := filepath.Dir(d)
+ if up == d {
+ break
+ }
+ d = up
+ }
+ for _, r := range roots {
+ if r == "" {
+ continue
+ }
+ for _, v := range []string{".grok", ".agents", ".claude", ".cursor"} {
+ bases = append(bases, filepath.Join(r, v))
+ }
+ }
+ bases = append(bases, GrokDir(), filepath.Join(GrokDir(), "bundled"))
+ for _, b := range bases {
+ if fileExists(filepath.Join(b, "skills", name, "SKILL.md")) || fileExists(filepath.Join(b, "commands", name+".md")) {
+ return name
+ }
+ }
+ return ""
+}
+
var tsKey = []byte(`"timestamp":`)
// numTS reads the time of a line from its first "timestamp" key when it is
diff --git a/internal/sessions/grok_tools_test.go b/internal/sessions/grok_tools_test.go
new file mode 100644
index 000000000..aa3ccc411
--- /dev/null
+++ b/internal/sessions/grok_tools_test.go
@@ -0,0 +1,91 @@
+package sessions
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+ "time"
+)
+
+// Grok Build's tool calls and skills (MaxMooreMy on X: "grok build 的工具
+// 调用啥的也没采集到"). The four sessions in testdata/grok-tools are real
+// grok 1.0.67 sessions, run headless (grok -p) in a sandbox home, byte for
+// byte; only the folder of their working directory is named shorter. In
+// one the model runs `cat notes.txt` and reads the greet-user skill's
+// SKILL.md with read_file; in one the user types /greet-user; one types
+// /nonexistentzz, a skill no folder has; one types /compact, Grok Build's
+// own command, marked hostTurn, which calls up no skill even with one of
+// that name about.
+func TestGrokToolsAndSkills(t *testing.T) {
+ inZone(t, 0)
+ claude, _ := setup(t)
+ home := filepath.Join(filepath.Dir(claude), "home")
+ copyTree(t, "testdata/grok-tools", filepath.Join(home, ".grok"))
+ compact := filepath.Join(home, ".grok", "skills", "compact")
+ os.MkdirAll(compact, 0o755)
+ os.WriteFile(filepath.Join(compact, "SKILL.md"), []byte("---\nname: compact\n---\n"), 0o644)
+
+ s := statsAt(0, time.Date(2026, 10, 29, 0, 0, 0, 0, time.UTC))
+ by := map[string]Summary{}
+ for _, x := range s.Sessions {
+ if x.Agent == "grok" {
+ by[x.ID] = x
+ }
+ }
+ if len(by) != 4 {
+ t.Fatalf("want the 4 Grok Build sessions, got %d", len(by))
+ }
+ called := by["01a1826b-5457-7d52-9706-c7e26b3fe171"]
+ if called.ToolCalls != 2 || called.tools.of("run_terminal_command") != 1 || called.tools.of("read_file") != 1 {
+ t.Fatalf("tools %d %v", called.ToolCalls, called.tools)
+ }
+ if called.skills.of("greet-user") != 1 || len(called.skills) != 1 {
+ t.Fatalf("the skill read: %v", called.skills)
+ }
+ typed := by["01a1826b-d49a-76b0-acf7-0a7a5a0a4dca"]
+ if typed.ToolCalls != 0 || typed.skills.of("greet-user") != 1 || len(typed.skills) != 1 {
+ t.Fatalf("/greet-user: %d %v", typed.ToolCalls, typed.skills)
+ }
+ for _, id := range []string{"01a1826c-64a3-7871-a4c1-5cfb6a077576", "01a1826c-7ff2-7f92-8ba4-feb3b83bad3a"} {
+ if x := by[id]; x.ToolCalls != 0 || len(x.skills) != 0 {
+ t.Fatalf("%s: %d %v", id, x.ToolCalls, x.skills)
+ }
+ }
+ o := s.Overview("", "", "", 10)
+ if o.Skills.Calls != 2 || o.Skills.Top[0].Name != "greet-user" || o.Skills.Top[0].Agents["grok"] != 2 {
+ t.Fatalf("overview skills %+v", o.Skills)
+ }
+}
+
+func TestGrokSlashSkill(t *testing.T) {
+ home := t.TempDir()
+ t.Setenv("HOME", home)
+ t.Setenv("USERPROFILE", home)
+ t.Setenv("GROK_HOME", "")
+ repo := filepath.Join(t.TempDir(), "repo")
+ cwd := filepath.Join(repo, "app")
+ for _, p := range []string{
+ filepath.Join(repo, ".claude", "skills", "frontend", "SKILL.md"),
+ filepath.Join(cwd, ".grok", "commands", "ship.md"),
+ filepath.Join(home, ".grok", "bundled", "skills", "review", "SKILL.md"),
+ filepath.Join(home, ".agents", "skills", "pdf", "SKILL.md"),
+ } {
+ os.MkdirAll(filepath.Dir(p), 0o755)
+ os.WriteFile(p, []byte("x"), 0o644)
+ }
+ for text, want := range map[string]string{
+ "/frontend": "frontend",
+ "/ship now please": "ship",
+ "/review\nthe diff": "review",
+ "/pdf": "pdf",
+ "/tmp is full": "",
+ "/../repo": "",
+ "please /review": "",
+ "/frontend/x": "",
+ "/nonexistentzz say ok": "",
+ } {
+ if got := grokSlashSkill(cwd, text); got != want {
+ t.Errorf("%q: %q, want %q", text, got, want)
+ }
+ }
+}
diff --git a/internal/sessions/sessions.go b/internal/sessions/sessions.go
index 7b71abc4b..77550f007 100644
--- a/internal/sessions/sessions.go
+++ b/internal/sessions/sessions.go
@@ -937,7 +937,8 @@ func CachePath() string { return filepath.Join(filepath.Dir(catalog.CachePath())
// 23: Claude Code's first and last message uuids (Root, Leaf).
// 24: Claude Code's compact summaries' uuids (Compacts).
// 25: the skills Codex calls up by reading their SKILL.md.
-const cacheVersion = 25
+// 26: Grok Build's tool calls and skills.
+const cacheVersion = 26
type cacheFile struct {
Version int `json:"version"`
diff --git a/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826b-5457-7d52-9706-c7e26b3fe171/summary.json b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826b-5457-7d52-9706-c7e26b3fe171/summary.json
new file mode 100644
index 000000000..4c0ccf109
--- /dev/null
+++ b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826b-5457-7d52-9706-c7e26b3fe171/summary.json
@@ -0,0 +1,25 @@
+{
+ "info": {
+ "id": "01a1826b-5457-7d52-9706-c7e26b3fe171",
+ "cwd": "/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/proj"
+ },
+ "agent_id": "ag1.5aab11693c87494ca0ad4d3ab531fd53",
+ "attempt_id": "at1.cfbae69bac0d487eac9dfe12fbd8cfff",
+ "session_summary": "Cat notes.txt then greet-user skill",
+ "created_at": "2026-10-28T12:10:34.561689Z",
+ "updated_at": "2026-10-28T12:10:47.177651Z",
+ "num_messages": 12,
+ "num_chat_messages": 11,
+ "current_model_id": "grok-4.7",
+ "next_trace_turn": 1,
+ "chat_format_version": 1,
+ "session_kind": "headless",
+ "git_root_dir": "/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/proj/",
+ "request_id": "e9f4ff57-78be-40d4-aae5-1f55275cbcd9",
+ "grok_home": "/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/.grok",
+ "last_active_at": "2026-10-28T12:10:47.177651Z",
+ "generated_title": "Cat notes.txt then greet-user skill",
+ "agent_name": "grok-build-plan",
+ "sandbox_profile": "off",
+ "reasoning_effort": "high"
+}
\ No newline at end of file
diff --git a/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826b-5457-7d52-9706-c7e26b3fe171/updates.jsonl b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826b-5457-7d52-9706-c7e26b3fe171/updates.jsonl
new file mode 100644
index 000000000..b80e0b908
--- /dev/null
+++ b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826b-5457-7d52-9706-c7e26b3fe171/updates.jsonl
@@ -0,0 +1,12 @@
+{"timestamp":1793189434,"method":"session/update","params":{"sessionId":"01a1826b-5457-7d52-9706-c7e26b3fe171","update":{"sessionUpdate":"user_message_chunk","content":{"type":"text","text":"First run the shell command `cat notes.txt` and tell me its output. Then use the greet-user skill to greet me."},"_meta":{"modelId":"grok-4.7","promptIndex":0}},"_meta":{"eventId":"01a1826b-5457-7d52-9706-c7e26b3fe171-2","agentTimestampMs":1793189434729}}}
+{"timestamp":1793189442,"method":"session/update","params":{"sessionId":"01a1826b-5457-7d52-9706-c7e26b3fe171","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":"I will run `cat notes.txt` and report its output.\n\nI will read the greet-user skill before greeting you."}},"_meta":{"totalTokens":1461,"requestTrimmedTokens":0,"eventId":"01a1826b-5457-7d52-9706-c7e26b3fe171-8","agentTimestampMs":1793189440323,"promptId":"e9f4ff57-78be-40d4-aae5-1f55275cbcd9","streamStartMs":1793189437057,"turnStartMs":1793189434720,"updateType":"AgentThoughtChunk","chunkId":5}}}
+{"timestamp":1793189443,"method":"session/update","params":{"sessionId":"01a1826b-5457-7d52-9706-c7e26b3fe171","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"I'll run `cat notes.txt` first, then read the greet-user skill so I can greet you the way it specifies."}},"_meta":{"totalTokens":1461,"requestTrimmedTokens":0,"eventId":"01a1826b-5457-7d52-9706-c7e26b3fe171-34","agentTimestampMs":1793189443144,"promptId":"e9f4ff57-78be-40d4-aae5-1f55275cbcd9","streamStartMs":1793189437057,"turnStartMs":1793189434720,"updateType":"AgentMessageChunk","chunkId":31}}}
+{"timestamp":1793189443,"method":"session/update","params":{"sessionId":"01a1826b-5457-7d52-9706-c7e26b3fe171","update":{"sessionUpdate":"tool_call","toolCallId":"call-d18ca66c-d58c-46f2-973e-4f43cf101230-0","title":"run_terminal_command","rawInput":{"command":"cat notes.txt","description":"Print contents of notes.txt"},"_meta":{"x.ai/tool":{"version":1,"name":"run_terminal_command","kind":"execute","namespace":"grok_build","label":"Run Command","read_only":false}}},"_meta":{"totalTokens":22781,"requestTrimmedTokens":0,"eventId":"01a1826b-5457-7d52-9706-c7e26b3fe171-36","agentTimestampMs":1793189443673,"promptId":"e9f4ff57-78be-40d4-aae5-1f55275cbcd9","streamStartMs":1793189437057,"turnStartMs":1793189434720,"updateType":"ToolCall","updateParams":{"toolCallId":"call-d18ca66c-d58c-46f2-973e-4f43cf101230-0","title":"run_terminal_command","kind":"Other","status":"Pending"}}}}
+{"timestamp":1793189443,"method":"session/update","params":{"sessionId":"01a1826b-5457-7d52-9706-c7e26b3fe171","update":{"sessionUpdate":"tool_call_update","toolCallId":"call-d18ca66c-d58c-46f2-973e-4f43cf101230-0","kind":"execute","title":"Execute `cat notes.txt`","content":[{"type":"content","content":{"type":"text","text":"Print contents of notes.txt"}}],"locations":[],"rawInput":{"variant":"Bash","command":"cat notes.txt","description":"Print contents of notes.txt","is_background":false},"_meta":{"x.ai/tool":{"version":1,"name":"run_terminal_command","kind":"execute","namespace":"grok_build","label":"Run Command","read_only":false,"input":{"command":"cat notes.txt","description":"Print contents of notes.txt"}}}},"_meta":{"totalTokens":22781,"requestTrimmedTokens":0,"eventId":"01a1826b-5457-7d52-9706-c7e26b3fe171-37","agentTimestampMs":1793189443677,"promptId":"e9f4ff57-78be-40d4-aae5-1f55275cbcd9","streamStartMs":1793189437057,"turnStartMs":1793189434720,"updateType":"ToolCallUpdate","updateParams":{"toolCallId":"call-d18ca66c-d58c-46f2-973e-4f43cf101230-0","status":null}}}}
+{"timestamp":1793189443,"method":"session/update","params":{"sessionId":"01a1826b-5457-7d52-9706-c7e26b3fe171","update":{"sessionUpdate":"tool_call","toolCallId":"call-d18ca66c-d58c-46f2-973e-4f43cf101230-1","title":"read_file","rawInput":{"target_file":"/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/.grok/skills/greet-user/SKILL.md"},"_meta":{"x.ai/tool":{"version":1,"name":"read_file","kind":"read","namespace":"grok_build","label":"Read","read_only":true}}},"_meta":{"totalTokens":22781,"requestTrimmedTokens":0,"eventId":"01a1826b-5457-7d52-9706-c7e26b3fe171-38","agentTimestampMs":1793189443706,"promptId":"e9f4ff57-78be-40d4-aae5-1f55275cbcd9","streamStartMs":1793189437057,"turnStartMs":1793189434720,"updateType":"ToolCall","updateParams":{"toolCallId":"call-d18ca66c-d58c-46f2-973e-4f43cf101230-1","title":"read_file","kind":"Other","status":"Pending"}}}}
+{"timestamp":1793189443,"method":"session/update","params":{"sessionId":"01a1826b-5457-7d52-9706-c7e26b3fe171","update":{"sessionUpdate":"tool_call_update","toolCallId":"call-d18ca66c-d58c-46f2-973e-4f43cf101230-1","kind":"read","title":"Read `/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/.grok/skills/greet-user/SKILL.md`","locations":[{"path":"/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/.grok/skills/greet-user/SKILL.md"}],"rawInput":{"variant":"ReadFile","target_file":"/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/.grok/skills/greet-user/SKILL.md"},"_meta":{"x.ai/tool":{"version":1,"name":"read_file","kind":"read","namespace":"grok_build","label":"Read","read_only":true,"input":{"path":"/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/.grok/skills/greet-user/SKILL.md"}}}},"_meta":{"totalTokens":22781,"requestTrimmedTokens":0,"eventId":"01a1826b-5457-7d52-9706-c7e26b3fe171-39","agentTimestampMs":1793189443707,"promptId":"e9f4ff57-78be-40d4-aae5-1f55275cbcd9","streamStartMs":1793189437057,"turnStartMs":1793189434720,"updateType":"ToolCallUpdate","updateParams":{"toolCallId":"call-d18ca66c-d58c-46f2-973e-4f43cf101230-1","status":null}}}}
+{"timestamp":1793189443,"method":"session/update","params":{"sessionId":"01a1826b-5457-7d52-9706-c7e26b3fe171","update":{"sessionUpdate":"tool_call_update","toolCallId":"call-d18ca66c-d58c-46f2-973e-4f43cf101230-1","status":"completed","content":[{"type":"content","content":{"type":"text","text":"1→---\nname: greet-user\ndescription: Use when the user asks to be greeted in the house style.\n---\nGreet the user with exactly: \"Ahoy from the greet-user skill!\"\n"}}],"rawOutput":{"type":"ReadFile","FileContent":{"content":"1→---\nname: greet-user\ndescription: Use when the user asks to be greeted in the house style.\n---\nGreet the user with exactly: \"Ahoy from the greet-user skill!\"\n","content_concise":"1→---\nname: greet-user\ndescription: Use when the user asks to be greeted in the house style.\n---\nGreet the user with exactly: \"Ahoy from the greet-user skill!\"\n","absolute_path":"/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/.grok/skills/greet-user/SKILL.md","offset":null,"raw_output":"---\nname: greet-user\ndescription: Use when the user asks to be greeted in the house style.\n---\nGreet the user with exactly: \"Ahoy from the greet-user skill!\"\n","total_lines":5}}},"_meta":{"totalTokens":22781,"requestTrimmedTokens":0,"eventId":"01a1826b-5457-7d52-9706-c7e26b3fe171-40","agentTimestampMs":1793189443735,"promptId":"e9f4ff57-78be-40d4-aae5-1f55275cbcd9","streamStartMs":1793189437057,"turnStartMs":1793189434720,"updateType":"ToolCallUpdate","updateParams":{"toolCallId":"call-d18ca66c-d58c-46f2-973e-4f43cf101230-1","status":"Completed"}}}}
+{"timestamp":1793189446,"method":"session/update","params":{"sessionId":"01a1826b-5457-7d52-9706-c7e26b3fe171","update":{"sessionUpdate":"tool_call_update","toolCallId":"call-d18ca66c-d58c-46f2-973e-4f43cf101230-0","status":"completed","content":[{"type":"content","content":{"type":"text","text":"hello\n"}}],"rawOutput":{"type":"Bash","output":[104,101,108,108,111,10],"output_for_prompt":"exit: 0\nhello\n","exit_code":0,"command":"cat notes.txt","truncated":false,"signal":null,"timed_out":false,"description":"Print contents of notes.txt","current_dir":"/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/proj","output_file":"/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/.grok/sessions/%2Fprivate%2Ftmp%2Fclaude-501%2F-Users-yetone-workspace-projects-magpie%2F4c056ab3-f2e6-4918-b774-da5c713ce1e3%2Fscratchpad%2Fgrokhome%2Fproj/01a1826b-5457-7d52-9706-c7e26b3fe171/terminal/call-d18ca66c-d58c-46f2-973e-4f43cf101230-0.log","total_bytes":6}},"_meta":{"totalTokens":22821,"requestTrimmedTokens":0,"eventId":"01a1826b-5457-7d52-9706-c7e26b3fe171-42","agentTimestampMs":1793189443747,"promptId":"e9f4ff57-78be-40d4-aae5-1f55275cbcd9","streamStartMs":1793189437057,"turnStartMs":1793189434720,"updateType":"ToolCallUpdate","updateParams":{"toolCallId":"call-d18ca66c-d58c-46f2-973e-4f43cf101230-0","status":"Completed"}}}}
+{"timestamp":1793189446,"method":"session/update","params":{"sessionId":"01a1826b-5457-7d52-9706-c7e26b3fe171","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":"The file `notes.txt` contains the text \"hello\"."}},"_meta":{"totalTokens":22824,"requestTrimmedTokens":0,"eventId":"01a1826b-5457-7d52-9706-c7e26b3fe171-46","agentTimestampMs":1793189446308,"promptId":"e9f4ff57-78be-40d4-aae5-1f55275cbcd9","streamStartMs":1793189445062,"turnStartMs":1793189434720,"updateType":"AgentThoughtChunk","chunkId":2}}}
+{"timestamp":1793189447,"method":"session/update","params":{"sessionId":"01a1826b-5457-7d52-9706-c7e26b3fe171","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"`cat notes.txt` printed:\n\n```\nhello\n```\n\nAhoy from the greet-user skill!"}},"_meta":{"totalTokens":22824,"requestTrimmedTokens":0,"eventId":"01a1826b-5457-7d52-9706-c7e26b3fe171-68","agentTimestampMs":1793189446923,"promptId":"e9f4ff57-78be-40d4-aae5-1f55275cbcd9","streamStartMs":1793189445062,"turnStartMs":1793189434720,"updateType":"AgentMessageChunk","chunkId":24}}}
+{"timestamp":1793189447,"method":"_x.ai/session/update","params":{"sessionId":"01a1826b-5457-7d52-9706-c7e26b3fe171","update":{"sessionUpdate":"turn_completed","prompt_id":"e9f4ff57-78be-40d4-aae5-1f55275cbcd9","stop_reason":"end_turn","usage":{"inputTokens":45075,"outputTokens":703,"totalTokens":45778,"cachedReadTokens":28928,"cacheCreationTokens":0,"reasoningTokens":554,"modelCalls":2,"apiDurationMs":11453,"costUsdTicks":509760000,"modelUsage":{"grok-4.7-build":{"inputTokens":45075,"outputTokens":703,"totalTokens":45778,"cachedReadTokens":28928,"cacheCreationTokens":0,"reasoningTokens":554,"modelCalls":2,"apiDurationMs":11453,"costUsdTicks":509760000}},"numTurns":2},"elapsed_ms":12429},"_meta":{"eventId":"01a1826b-5457-7d52-9706-c7e26b3fe171-72","agentTimestampMs":1793189447150}}}
diff --git a/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826b-d49a-76b0-acf7-0a7a5a0a4dca/summary.json b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826b-d49a-76b0-acf7-0a7a5a0a4dca/summary.json
new file mode 100644
index 000000000..5954c8de3
--- /dev/null
+++ b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826b-d49a-76b0-acf7-0a7a5a0a4dca/summary.json
@@ -0,0 +1,24 @@
+{
+ "info": {
+ "id": "01a1826b-d49a-76b0-acf7-0a7a5a0a4dca",
+ "cwd": "/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/proj"
+ },
+ "agent_id": "ag1.e1d45854a5a9475da338af8a5f3f6c6c",
+ "attempt_id": "at1.3fc42ba3902e4331931baca11948159d",
+ "session_summary": "",
+ "created_at": "2026-10-28T12:11:07.300112Z",
+ "updated_at": "2026-10-28T12:11:11.428145Z",
+ "num_messages": 3,
+ "num_chat_messages": 7,
+ "current_model_id": "grok-4.7",
+ "next_trace_turn": 1,
+ "chat_format_version": 1,
+ "session_kind": "headless",
+ "git_root_dir": "/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/proj/",
+ "request_id": "e4baa3d2-7bdf-4820-ac7b-8883fbc5df2b",
+ "grok_home": "/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/.grok",
+ "last_active_at": "2026-10-28T12:11:11.428145Z",
+ "agent_name": "grok-build-plan",
+ "sandbox_profile": "off",
+ "reasoning_effort": "high"
+}
\ No newline at end of file
diff --git a/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826b-d49a-76b0-acf7-0a7a5a0a4dca/updates.jsonl b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826b-d49a-76b0-acf7-0a7a5a0a4dca/updates.jsonl
new file mode 100644
index 000000000..ead1b1a0e
--- /dev/null
+++ b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826b-d49a-76b0-acf7-0a7a5a0a4dca/updates.jsonl
@@ -0,0 +1,3 @@
+{"timestamp":1793189467,"method":"session/update","params":{"sessionId":"01a1826b-d49a-76b0-acf7-0a7a5a0a4dca","update":{"sessionUpdate":"user_message_chunk","content":{"type":"text","text":"/greet-user"},"_meta":{"modelId":"grok-4.7","promptIndex":0}},"_meta":{"eventId":"01a1826b-d49a-76b0-acf7-0a7a5a0a4dca-2","agentTimestampMs":1793189467452}}}
+{"timestamp":1793189471,"method":"session/update","params":{"sessionId":"01a1826b-d49a-76b0-acf7-0a7a5a0a4dca","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"Ahoy from the greet-user skill!"}},"_meta":{"totalTokens":1528,"requestTrimmedTokens":0,"eventId":"01a1826b-d49a-76b0-acf7-0a7a5a0a4dca-12","agentTimestampMs":1793189471185,"promptId":"e4baa3d2-7bdf-4820-ac7b-8883fbc5df2b","streamStartMs":1793189469748,"turnStartMs":1793189467443,"updateType":"AgentMessageChunk","chunkId":9}}}
+{"timestamp":1793189471,"method":"_x.ai/session/update","params":{"sessionId":"01a1826b-d49a-76b0-acf7-0a7a5a0a4dca","update":{"sessionUpdate":"turn_completed","prompt_id":"e4baa3d2-7bdf-4820-ac7b-8883fbc5df2b","stop_reason":"end_turn","usage":{"inputTokens":22347,"outputTokens":51,"totalTokens":22398,"cachedReadTokens":6784,"cacheCreationTokens":0,"reasoningTokens":42,"modelCalls":1,"apiDurationMs":3064,"costUsdTicks":348240000,"modelUsage":{"grok-4.7-build":{"inputTokens":22347,"outputTokens":51,"totalTokens":22398,"cachedReadTokens":6784,"cacheCreationTokens":0,"reasoningTokens":42,"modelCalls":1,"apiDurationMs":3064,"costUsdTicks":348240000}},"numTurns":1},"elapsed_ms":3966},"_meta":{"eventId":"01a1826b-d49a-76b0-acf7-0a7a5a0a4dca-16","agentTimestampMs":1793189471410}}}
diff --git a/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826c-64a3-7871-a4c1-5cfb6a077576/summary.json b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826c-64a3-7871-a4c1-5cfb6a077576/summary.json
new file mode 100644
index 000000000..441c9d10a
--- /dev/null
+++ b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826c-64a3-7871-a4c1-5cfb6a077576/summary.json
@@ -0,0 +1,25 @@
+{
+ "info": {
+ "id": "01a1826c-64a3-7871-a4c1-5cfb6a077576",
+ "cwd": "/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/proj"
+ },
+ "agent_id": "ag1.9c713fe015244911829db0e41b0b8ef2",
+ "attempt_id": "at1.e4f0f7dc98564169b8eaca8f746f6633",
+ "session_summary": "Nonexistentzz command requests simple ok response",
+ "created_at": "2026-10-28T12:11:44.189178Z",
+ "updated_at": "2026-10-28T12:11:49.729971Z",
+ "num_messages": 4,
+ "num_chat_messages": 7,
+ "current_model_id": "grok-4.7",
+ "next_trace_turn": 1,
+ "chat_format_version": 1,
+ "session_kind": "headless",
+ "git_root_dir": "/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/proj/",
+ "request_id": "0cbdb19f-66ce-4e42-a685-bb31630aa25c",
+ "grok_home": "/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/.grok",
+ "last_active_at": "2026-10-28T12:11:49.159027Z",
+ "generated_title": "Nonexistentzz command requests simple ok response",
+ "agent_name": "grok-build-plan",
+ "sandbox_profile": "off",
+ "reasoning_effort": "high"
+}
\ No newline at end of file
diff --git a/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826c-64a3-7871-a4c1-5cfb6a077576/updates.jsonl b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826c-64a3-7871-a4c1-5cfb6a077576/updates.jsonl
new file mode 100644
index 000000000..d147eb344
--- /dev/null
+++ b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826c-64a3-7871-a4c1-5cfb6a077576/updates.jsonl
@@ -0,0 +1,4 @@
+{"timestamp":1793189504,"method":"session/update","params":{"sessionId":"01a1826c-64a3-7871-a4c1-5cfb6a077576","update":{"sessionUpdate":"user_message_chunk","content":{"type":"text","text":"/nonexistentzz say ok"},"_meta":{"modelId":"grok-4.7","promptIndex":0}},"_meta":{"eventId":"01a1826c-64a3-7871-a4c1-5cfb6a077576-2","agentTimestampMs":1793189504352}}}
+{"timestamp":1793189508,"method":"session/update","params":{"sessionId":"01a1826c-64a3-7871-a4c1-5cfb6a077576","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":"The user wants me to run the command \"/nonexistentzz say ok\"."}},"_meta":{"totalTokens":1439,"requestTrimmedTokens":0,"eventId":"01a1826c-64a3-7871-a4c1-5cfb6a077576-6","agentTimestampMs":1793189508855,"promptId":"0cbdb19f-66ce-4e42-a685-bb31630aa25c","streamStartMs":1793189506692,"turnStartMs":1793189504345,"updateType":"AgentThoughtChunk","chunkId":3}}}
+{"timestamp":1793189509,"method":"session/update","params":{"sessionId":"01a1826c-64a3-7871-a4c1-5cfb6a077576","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"ok"}},"_meta":{"totalTokens":1439,"requestTrimmedTokens":0,"eventId":"01a1826c-64a3-7871-a4c1-5cfb6a077576-7","agentTimestampMs":1793189508855,"promptId":"0cbdb19f-66ce-4e42-a685-bb31630aa25c","streamStartMs":1793189506692,"turnStartMs":1793189504345,"updateType":"AgentMessageChunk","chunkId":4}}}
+{"timestamp":1793189509,"method":"_x.ai/session/update","params":{"sessionId":"01a1826c-64a3-7871-a4c1-5cfb6a077576","update":{"sessionUpdate":"turn_completed","prompt_id":"0cbdb19f-66ce-4e42-a685-bb31630aa25c","stop_reason":"end_turn","usage":{"inputTokens":22215,"outputTokens":176,"totalTokens":22391,"cachedReadTokens":6656,"cacheCreationTokens":0,"reasoningTokens":175,"modelCalls":1,"apiDurationMs":3802,"costUsdTicks":355020000,"modelUsage":{"grok-4.7-build":{"inputTokens":22215,"outputTokens":176,"totalTokens":22391,"cachedReadTokens":6656,"cacheCreationTokens":0,"reasoningTokens":175,"modelCalls":1,"apiDurationMs":3802,"costUsdTicks":355020000}},"numTurns":1},"elapsed_ms":4795},"_meta":{"eventId":"01a1826c-64a3-7871-a4c1-5cfb6a077576-11","agentTimestampMs":1793189509141}}}
diff --git a/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826c-7ff2-7f92-8ba4-feb3b83bad3a/summary.json b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826c-7ff2-7f92-8ba4-feb3b83bad3a/summary.json
new file mode 100644
index 000000000..1e14050c4
--- /dev/null
+++ b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826c-7ff2-7f92-8ba4-feb3b83bad3a/summary.json
@@ -0,0 +1,24 @@
+{
+ "info": {
+ "id": "01a1826c-7ff2-7f92-8ba4-feb3b83bad3a",
+ "cwd": "/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/proj"
+ },
+ "agent_id": "ag1.99beb0873bd473a959676876b502b1b",
+ "attempt_id": "at1.69cd11cac8eb4cd595e16fae8d3aa8d4",
+ "session_summary": "",
+ "created_at": "2026-10-28T12:11:51.169722Z",
+ "updated_at": "2026-10-28T12:13:42.380440Z",
+ "num_messages": 4,
+ "num_chat_messages": 5,
+ "current_model_id": "grok-4.7",
+ "next_trace_turn": 1,
+ "chat_format_version": 1,
+ "session_kind": "headless",
+ "git_root_dir": "/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/proj/",
+ "request_id": "031432c3-fdc1-495e-bda2-08b5dd593ee8",
+ "grok_home": "/private/tmp/claude-501/-Users-yetone-workspace-projects-magpie/4c056ab3-f2e6-4918-b774-da5c713ce1e3/scratchpad/grokhome/.grok",
+ "last_active_at": "2026-10-28T12:13:42.380440Z",
+ "agent_name": "grok-build-plan",
+ "sandbox_profile": "off",
+ "reasoning_effort": "high"
+}
\ No newline at end of file
diff --git a/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826c-7ff2-7f92-8ba4-feb3b83bad3a/updates.jsonl b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826c-7ff2-7f92-8ba4-feb3b83bad3a/updates.jsonl
new file mode 100644
index 000000000..87e4469fc
--- /dev/null
+++ b/internal/sessions/testdata/grok-tools/sessions/%2Fwork%2Fgrok-tools/01a1826c-7ff2-7f92-8ba4-feb3b83bad3a/updates.jsonl
@@ -0,0 +1,4 @@
+{"timestamp":1793189622,"method":"_x.ai/session/update","params":{"sessionId":"01a1826c-7ff2-7f92-8ba4-feb3b83bad3a","update":{"sessionUpdate":"compaction_checkpoint","checkpoint_id":"35a260f1-351f-4cec-97e8-39dc53a340a1","prompt_index_at_compaction":0,"checkpoint_file":"compaction_checkpoints/35a260f1-351f-4cec-97e8-39dc53a340a1.json","schema_version":1,"created_at":"2026-10-28T12:13:42.144253+00:00"},"_meta":{"eventId":"01a1826c-7ff2-7f92-8ba4-feb3b83bad3a-3","agentTimestampMs":1793189622144}}}
+{"timestamp":1793189622,"method":"_x.ai/session/update","params":{"sessionId":"01a1826c-7ff2-7f92-8ba4-feb3b83bad3a","update":{"sessionUpdate":"auto_compact_completed","tokens_before":1266,"tokens_after":1266,"summary_preview":null},"_meta":{"eventId":"01a1826c-7ff2-7f92-8ba4-feb3b83bad3a-4","agentTimestampMs":1793189622144}}}
+{"timestamp":1793189622,"method":"session/update","params":{"sessionId":"01a1826c-7ff2-7f92-8ba4-feb3b83bad3a","update":{"sessionUpdate":"user_message_chunk","content":{"type":"text","text":"/compact"},"_meta":{"hostTurn":true}},"_meta":{"eventId":"01a1826c-7ff2-7f92-8ba4-feb3b83bad3a-2","agentTimestampMs":1793189511341}}}
+{"timestamp":1793189622,"method":"_x.ai/session/update","params":{"sessionId":"01a1826c-7ff2-7f92-8ba4-feb3b83bad3a","update":{"sessionUpdate":"turn_completed","prompt_id":"031432c3-fdc1-495e-bda2-08b5dd593ee8","stop_reason":"end_turn","elapsed_ms":110808},"_meta":{"eventId":"01a1826c-7ff2-7f92-8ba4-feb3b83bad3a-5","agentTimestampMs":1793189622145}}}
diff --git a/internal/sessions/testdata/grok-tools/skills/greet-user/SKILL.md b/internal/sessions/testdata/grok-tools/skills/greet-user/SKILL.md
new file mode 100644
index 000000000..d7582f581
--- /dev/null
+++ b/internal/sessions/testdata/grok-tools/skills/greet-user/SKILL.md
@@ -0,0 +1,5 @@
+---
+name: greet-user
+description: Use when the user asks to be greeted in the house style.
+---
+Greet the user with exactly: "Ahoy from the greet-user skill!"