Commit Graph
1 Commits
Author SHA1 Message Date
yetone 1feee38d17 sessions: Codex's skills are counted, from its reads of their SKILL.md (MaxMooreMy on X)
MaxMooreMy on X: "magpie的skill调用统计是不是坏了。用了一天,一个都没统计到".
The screenshot is Usage → Sessions, Codex (gpt-6-astra), 10 sessions,
Tool use "exec 488": Top skills says no skill was called up.

Cause: nothing ever counted a Codex skill. Codex has no tool for skills:
its <skills_instructions> list each skill's SKILL.md, and the model calls
one up by reading that file through a shell command, now from inside a
code-mode exec script (tools.exec_command({cmd:"cat '.../imagegen/
SKILL.md'"})), before that through exec_command, shell or a
local_shell_call. codexHead counted each call's tool and passed "" for
the skill, so only Claude Code (Skill tool), Alma and Pi/omp had skills.
Not a regression: efd1b697e and the other recent sessions commits don't
touch this; no version of codex.go counted one.

Now cxSkillReads reads a call line that holds "SKILL.md" (only those are
decoded) and counts each skill whose SKILL.md path it names, by its
folder, once a call: the exec script's input, a function call's
arguments, a local_shell_call's command. A patch writing a SKILL.md, a
redirect or tee into one, a bare SKILL.md with no folder (find -name,
grep) and a glob count none. The sessions cache goes to 25 so cached
Codex files are read again.

Run (all on mote, through mote-run, at this tree):
- go test -tags nogui ./internal/sessions/: ok.
- TestCodexSkillReads: two real call lines from this Mac's rollouts, byte
  for byte (2026-08-07's code-mode exec, 2026-07-26's exec_command, its
  timestamp moved to the same day), plus a patch, a heredoc redirect and
  a find. TestCxSkillReads: shell, local_shell_call, a Windows
  Get-Content path, and the reads that count none.
- Real sessions in a sandbox CODEX_HOME: 19 rollouts copied read-only
  from ~/.codex/sessions (15 August ones with an imagegen read through
  exec, today's 4). Old code: skills calls=0. New: imagegen 15 calls in
  15 sessions, agent codex.
- Across all 11,846 compressed rollouts here, the exec calls naming a
  SKILL.md were grouped by how they read it (cat, /bin/cat, sed -n, awk,
  perl, wc && sed, `done < file`); each form is a read the rule counts.
- Broken by hand: with the loop that counts cxSkillReads' skills taken
  out, TestCodexSkillReads fails ("skills []") and the real sandbox reads
  0.
- go test -tags nogui of the packages importing sessions: usage, cli,
  tui, tune, otlp, davsync ok; gui had TestRestartHandsTheGatewayOver red
  once in the parallel run (#3451, open), 3 of 3 alone.
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags nogui
  of internal/sessions ok.

Not tried: the GUI against a live magpie (the page only shows what
Overview returns; app.js unchanged, so no GUI suite run); a SKILL.md read
through tools the rule doesn't know (a plugin's own read tool) and a
skill whose SKILL.md sits in a nested folder (clawra-selfie/skill/
SKILL.md counts as "skill"); internal/gateway and internal/agent, which
import sessions for other things. Other agents with no skill count
(Droid, Kimi Code, Hermes, Cursor, Antigravity) have no real session
here to build from: #4037.
2026-10-28 17:34:27 +08:00