Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
usage: a new Codex thread keeps the chunks read before (#3493)
yetone57a70aaf101b
diff --git a/internal/usage/codex_identity_test.go b/internal/usage/codex_identity_test.goindex 434bec670..9c1e6302f 100644--- a/internal/usage/codex_identity_test.go+++ b/internal/usage/codex_identity_test.go@@ -494,3 +494,31 @@ func TestCodexModelEffortReadsLedgerOnlyWhenCallsChange(t *testing.T) {t.Fatalf("a new gateway call did not read the ledger again: built %d", built)}}++// A new Codex thread, a subagent's too, keeps the chunks of the files read+// before (#3493): a thread's identity is given to its rows as the page is+// built, so a child read before its parent's file names the parent's+// session once that file is there, and nothing else is read again.+func TestCodexNewThreadKeepsReadChunks(t *testing.T) {+ pageHome(t)+ now := holdClock(t, time.Date(2026, 9, 30, 12, 0, 0, 0, time.UTC))+ dir := filepath.Join(sessions.CodexDir(), "sessions", "2026", "09", "30")+ var read []string+ reader := func(s sessions.CallSource) []sessions.Call {+ read = append(read, filepath.Base(s.Path))+ return sessions.ReadCallSource(s)+ }+ writeCodexCall(t, filepath.Join(dir, "rollout-2026-09-30T10-00-00-child-b.jsonl"), "child-b", "shared-b", `{"subagent":{"thread_spawn":{"parent_thread_id":"main-a"}}}`, "resp-b", "m", "low", now.Add(-time.Hour), 100, 10)+ if p := queryPage(Today, Filter{}, 0, 100, reader); p.Total != 1 {+ t.Fatalf("%d rows", p.Total)+ }+ read = nil+ writeCodexCall(t, filepath.Join(dir, "rollout-2026-09-30T10-00-00-main-a.jsonl"), "main-a", "shared-a", `"vscode"`, "resp-a", "m", "low", now.Add(-2*time.Hour), 300, 30)+ p := queryPage(Today, Filter{}, 0, 100, reader)+ if len(read) != 1 || read[0] != "rollout-2026-09-30T10-00-00-main-a.jsonl" {+ t.Fatalf("a new thread read again %v", read)+ }+ if row, ok := findRowByResponse(p.Rows, "resp-b"); !ok || row.SessionRole != "subagent" || row.Session != "main-a" {+ t.Fatalf("the child's row doesn't name its parent's session: %+v, found=%t", row, ok)+ }+}diff --git a/internal/usage/request_page.go b/internal/usage/request_page.goindex abf374762..a14bc2703 100644--- a/internal/usage/request_page.go+++ b/internal/usage/request_page.go@@ -418,7 +418,11 @@ func recordHash(path string, n int64) string {// requestState is what the calls read at now depend on: the gateway log's// snapshot, the agents' call files, other computers' days, Codex's thread// identities and what prices and names a call. A change to meta drops the-// request index's chunks; a change to key, its pages.+// request index's chunks; a change to key, its pages. Codex's thread+// identities are in key alone: a chunk's rows don't hold them, the page+// gives them to its rows as it is built, and every new Codex thread, a+// subagent's too, dropped every chunk, so the next page read the whole+// history again (#3493).type requestState struct {sources []sessions.CallSourcecodexIdentities map[string]sessions.CodexIdentity@@ -444,7 +448,7 @@ func readRequestState(now time.Time) requestState {cfg := settings.Load()prices, _ := json.Marshal(cfg.ModelPrices)wires, _ := json.Marshal(cfg.ModelWires)- meta := fmt.Sprintf("%s|%s|%s|%s|%s|%s|%s|%s", ids, codexIdentityKey, renamed, prices, wires, statKey(provider.Path()), statKey(catalog.CachePath()), clientAgentsKey())+ meta := fmt.Sprintf("%s|%s|%s|%s|%s|%s|%s", ids, renamed, prices, wires, statKey(provider.Path()), statKey(catalog.CachePath()), clientAgentsKey())h := sha256.New()for _, current := range provider.All() {fmt.Fprintf(h, "%q:%q:%v:%t:%t:%t;", current.ID, current.Where(), current.Catalogs(), current.IsPlugin(), current.Account == nil, current.Key != "")@@ -462,6 +466,7 @@ func readRequestState(now time.Time) requestState {h.Reset()snapshot := readLogSnapshot()fmt.Fprint(h, meta, snapshot.version, now.In(time.Local).Format("2006-01-02 MST"))+ h.Write(codexIdentityKey)for _, s := range sources {fmt.Fprintf(h, "%s:%d:%d;", s.Path, s.Size, s.Modified.UnixNano())}