From 3869aee3b0e68cbda626853c99565e4e33f962dc Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 19 Nov 2026 10:05:14 +0800 Subject: [PATCH] =?UTF-8?q?sessions:=20agy's=20calls=20in=20T3=20Code=20ar?= =?UTF-8?q?e=20on=20Usage=20=E2=86=92=20Requests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit zzzkl on X: requests from Antigravity in T3 Code weren't on Usage → Requests, while a plain agy's were. T3 Code (pingdotgg/t3code, read at 00c6adbd) runs agy for each Antigravity instance as an ACP server on the instance's own Google sign-in: `agy acp --gemini-dir --app-data-dir antigravity-acp` (antigravityAuthSupport.ts), the profile being /userdata/providers/antigravity/, the folder $T3CODE_HOME or ~/.t3 (dev for its dev server). Those requests go to Google, never through the gateway, and magpie's agy reader looked only in ~/.gemini/antigravity-cli, so nothing counted them. agy writes the same transcript_full.jsonl there as in its own folder (agy 1.5.10 run that way in a sandbox against a fake Gemini endpoint; the fixture is its bytes). agyCallFiles now reads every T3 Code profile's antigravity-acp too, and Found lists agy for those folders, so the read consent covers them. T3 Code's folder is appdir.T3Code, shared with agent's t3Base. Siblings: `agy acp` from any other ACP client with the defaults writes to antigravity-cli, already read (agy acp --help). T3 Code's magpie instances (Claude, Codex) go through the gateway and are counted there. Run: TestAgyCallsInT3Code (default folder, T3CODE_HOME, ~/ form) red on the old calls_agy.go/access.go with 0 calls, and with Found() = [claude codex] when only access.go is old; green with the change. gofmt -l clean; go vet (darwin, GOOS=linux, GOOS=windows) of appdir, agent and sessions on mote. Full suite (go test -timeout 45m ./..., mica, at 0e3d09361 plus this): every package ok but agent, dirent, gateway, gui, library and profile; each red was run again at the base: TestWSLAgentFolderIsALink 2 of 12 red at the base too (filed #7150), the dirent watch tests and TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes red at the base (#7031, #7117), TestGatewayModeListsNoOwnSessions (#7064) ok alone, library and profile hung in testenv.warmAt (#5267) and ok alone. After the rebase on 14b6b9555 (this commit's tree): appdir ok, agent ok but TestWSLAgentFolderIsALink (#7150), sessions ok (2335s). Rebased again onto 9768b384e (its three commits touch none of sessions, agent or appdir): go build ./... and the TestAgy/T3 tests of sessions and agent ok at this commit. No GUI file is reached (no string, API or page change). Not tried: a real T3 Code signed in to Google (the profile layout is from T3's source, agy's files from a real agy acp); T3 Code in WSL; a plain agy with its own GEMINI_HOME/--gemini-dir. The calls count as agy (Antigravity CLI), not T3 Code, and the Sessions page doesn't list these conversations (agy --conversation would look in agy's own folder). T3's throwaway helper sessions delete their files, so their calls go too. --- docs/subsystems/gateway-sessions.md | 9 +++ internal/agent/t3code.go | 11 +--- internal/appdir/t3code.go | 21 +++++++ internal/sessions/access.go | 6 +- internal/sessions/calls_agy.go | 52 ++++++++++++++-- internal/sessions/calls_agy_t3_test.go | 60 +++++++++++++++++++ .../logs/transcript_full.jsonl | 2 + 7 files changed, 145 insertions(+), 16 deletions(-) create mode 100644 internal/appdir/t3code.go create mode 100644 internal/sessions/calls_agy_t3_test.go create mode 100644 internal/sessions/testdata/agy-t3/brain/f8dd5efd-4ce8-499e-8359-ac13b3b2dd03/.system_generated/logs/transcript_full.jsonl diff --git a/docs/subsystems/gateway-sessions.md b/docs/subsystems/gateway-sessions.md index 462504d2c..cbe773fcf 100644 --- a/docs/subsystems/gateway-sessions.md +++ b/docs/subsystems/gateway-sessions.md @@ -1011,6 +1011,15 @@ picks it up from any folder; when agy is set to use magpie it is the agent's launch command (the gateway's variables and `--model`) with `--conversation` after it (`sessions.AgyStart`, set by package agent). Subagents (`parent_conversation_id`) and agy in WSL are not read. +agy's calls are also read from the profile T3 Code gives each of its +Antigravity instances (`t3AgyDirs`): T3 Code runs `agy acp --gemini-dir + --app-data-dir antigravity-acp` on the instance's own Google +sign-in, the profile under `/userdata/providers/antigravity/` +(or `dev/…` for its dev server; the folder is `$T3CODE_HOME` or `~/.t3`, +`appdir.T3Code`), and those requests go to Google, not through the gateway +(zzzkl on X; `TestAgyCallsInT3Code`, on what agy 1.5.10 wrote run that way). +`Found` lists agy for those folders too. The Sessions page doesn't list +them: `agy --conversation` would look in agy's own folder. Verification: `TestAgySessions`, `TestAgyTitleLater`, `TestAgyGrows`, `TestAgyTranscript`, `TestAgyFolder`, `TestAgyRowOnly`, on conversations agy 1.3.5 and 1.4.7 wrote in a sandbox. diff --git a/internal/agent/t3code.go b/internal/agent/t3code.go index c521f6592..736176067 100644 --- a/internal/agent/t3code.go +++ b/internal/agent/t3code.go @@ -82,16 +82,7 @@ const t3CodexOffered = "t3code.codex" // t3Base is T3 Code's folder for home: $T3CODE_HOME, else ~/.t3. Its // settings are userdata/settings.json in it. -func t3Base(home string) string { - base := appdir.Getenv("T3CODE_HOME") - if base == "" { - return filepath.Join(home, ".t3") - } - if rest, ok := strings.CutPrefix(base, "~"); ok { - return filepath.Join(home, rest) - } - return base -} +func t3Base(home string) string { return appdir.T3Code(home) } // t3CodexRunsIn reports whether T3 Code's settings for home have magpie's // Codex instance (t3CodexInstance) running Codex in the Codex home dir: diff --git a/internal/appdir/t3code.go b/internal/appdir/t3code.go new file mode 100644 index 000000000..ee8411bf4 --- /dev/null +++ b/internal/appdir/t3code.go @@ -0,0 +1,21 @@ +package appdir + +import ( + "path/filepath" + "strings" +) + +// T3Code is T3 Code's folder (pingdotgg/t3code) for home: $T3CODE_HOME, +// a leading ~ being home, else ~/.t3 (resolveBaseDir in its server's +// os-jank.ts). Its settings, and each provider instance's profile, are in +// userdata in it. +func T3Code(home string) string { + base := Getenv("T3CODE_HOME") + if base == "" { + return filepath.Join(home, ".t3") + } + if rest, ok := strings.CutPrefix(base, "~"); ok { + return filepath.Join(home, rest) + } + return base +} diff --git a/internal/sessions/access.go b/internal/sessions/access.go index 311ad904d..6c747cbb0 100644 --- a/internal/sessions/access.go +++ b/internal/sessions/access.go @@ -273,7 +273,11 @@ func Found() []string { kimi = append(kimi, filepath.Join(kimiWorkRuntime(sh), "home", "sessions")) } add("kimi", kimi...) - add("agy", filepath.Join(AgyDir(), "brain")) + var agy []string + for _, d := range agyDataDirs() { + agy = append(agy, filepath.Join(d, "brain")) + } + add("agy", agy...) add("antigravity", antigravityConversations(), filepath.Join(AntigravityInsidersDir(), "conversations")) add("gemini", geminiTmpDir()) var devin []string diff --git a/internal/sessions/calls_agy.go b/internal/sessions/calls_agy.go index 664d56a29..66adf4132 100644 --- a/internal/sessions/calls_agy.go +++ b/internal/sessions/calls_agy.go @@ -13,6 +13,9 @@ import ( "strconv" "strings" "time" + + "github.com/yetone/magpie/internal/appdir" + "github.com/yetone/magpie/internal/dirent" ) // Antigravity CLI's (agy's) calls (#2097, parkavenue9639: a call agy made @@ -57,12 +60,51 @@ func AgyDir() string { return filepath.Join(home, ".gemini", "antigravity-cli") } -// agyCallFiles are each conversation's transcript_full.jsonl. A file's size -// and time take in its conversation's database and write-ahead log, so a -// model agy writes there after the step is read still reads the calls -// again. +// T3 Code (pingdotgg/t3code) runs agy for each Antigravity instance of +// its own, as an ACP server on the instance's Google sign-in: +// `agy acp --gemini-dir --app-data-dir antigravity-acp`, the +// profile being /userdata/providers/antigravity/ (antigravityAuthSupport.ts), T3 Code's folder +// $T3CODE_HOME or ~/.t3 (dev in place of userdata for a T3 Code run from +// its dev server). agy writes each conversation there as it does in its own folder +// (agy 1.5.10 in a sandbox against a fake Gemini endpoint: +// brain//.system_generated/logs/transcript_full.jsonl and +// conversations/.db under antigravity-acp), and its requests go to +// Google, not through magpie, so they are counted from those files +// (zzzkl on X: agy's calls in T3 Code weren't on Usage → Requests, a +// plain agy's were). +func t3AgyDirs() []string { + home, _ := os.UserHomeDir() + base := appdir.T3Code(home) + var out []string + for _, state := range []string{"userdata", "dev"} { + root := filepath.Join(base, state, "providers", "antigravity") + dirs, _ := os.ReadDir(root) + for _, d := range dirs { + if dirent.IsFolder(root, d) { + out = append(out, filepath.Join(root, d.Name(), "antigravity-acp")) + } + } + } + return out +} + +// agyDataDirs are the folders agy keeps conversations in on this computer: +// its own (AgyDir) and each T3 Code profile's (t3AgyDirs). +func agyDataDirs() []string { return append([]string{AgyDir()}, t3AgyDirs()...) } + +// agyCallFiles are each conversation's transcript_full.jsonl, in every +// folder agy keeps them in (agyDataDirs). A file's size and time take in +// its conversation's database and write-ahead log, so a model agy writes +// there after the step is read still reads the calls again. func agyCallFiles() []file { - out := agyTranscripts(AgyDir()) + if !Reads("agy") { + return nil + } + var out []file + for _, d := range agyDataDirs() { + out = append(out, agyTranscripts(d)...) + } for i := range out { agyCallStat(&out[i]) } diff --git a/internal/sessions/calls_agy_t3_test.go b/internal/sessions/calls_agy_t3_test.go new file mode 100644 index 000000000..6e2e9fc38 --- /dev/null +++ b/internal/sessions/calls_agy_t3_test.go @@ -0,0 +1,60 @@ +package sessions + +import ( + "crypto/sha256" + "encoding/hex" + "path/filepath" + "slices" + "testing" + "time" +) + +// zzzkl on X: agy's calls made in T3 Code weren't on Usage → Requests, +// while a plain agy's were. T3 Code runs agy as an ACP server in a profile +// of its own per Antigravity instance, and agy keeps that instance's +// conversations there. testdata/agy-t3 is what agy 1.5.10 wrote under +// antigravity-acp when started as T3 Code starts it (`agy acp +// --gemini-dir --app-data-dir antigravity-acp`) in a sandbox +// against a fake Gemini endpoint, one turn of one model step. +func TestAgyCallsInT3Code(t *testing.T) { + sum := sha256.Sum256([]byte("antigravity")) // T3 Code's own instance's id + profile := hex.EncodeToString(sum[:]) + for _, c := range []struct { + name string + base func(home, dir string) string // $T3CODE_HOME; nil leaves it unset + at func(home, dir string) string + }{ + {"default folder", nil, func(home, _ string) string { return filepath.Join(home, ".t3") }}, + {"T3CODE_HOME", func(_, dir string) string { return filepath.Join(dir, "t3home") }, func(_, dir string) string { return filepath.Join(dir, "t3home") }}, + {"T3CODE_HOME under ~", func(_, _ string) string { return "~/t3elsewhere" }, func(home, _ string) string { return filepath.Join(home, "t3elsewhere") }}, + } { + t.Run(c.name, func(t *testing.T) { + claude, _ := setup(t) + dir := filepath.Dir(claude) + home := filepath.Join(dir, "home") + if c.base != nil { + t.Setenv("T3CODE_HOME", c.base(home, dir)) + } + copyTree(t, "testdata/agy-t3", filepath.Join(c.at(home, dir), "userdata", "providers", "antigravity", profile, "antigravity-acp")) + + var got []Call + for _, call := range Calls(time.Time{}) { + if call.Agent == "agy" { + got = append(got, call) + } + } + if len(got) != 1 { + t.Fatalf("want the one model step of T3 Code's agy conversation, got %d calls: %+v", len(got), got) + } + at, _ := time.Parse(time.RFC3339, "2026-11-19T01:06:24Z") + want := Tokens{Input: 1034, CacheRead: 200, Output: 56} + if g := got[0]; !g.Time.Equal(at) || g.Session != "f8dd5efd-4ce8-499e-8359-ac13b3b2dd03" || g.Tokens != want { + t.Errorf("call %v %s %+v, want %v f8dd5efd-… %+v", g.Time, g.Session, g.Tokens, at, want) + } + // the consent lists agy for these files alone + if !slices.Contains(Found(), "agy") { + t.Errorf("Found() = %v, want agy for T3 Code's agy conversations", Found()) + } + }) + } +} diff --git a/internal/sessions/testdata/agy-t3/brain/f8dd5efd-4ce8-499e-8359-ac13b3b2dd03/.system_generated/logs/transcript_full.jsonl b/internal/sessions/testdata/agy-t3/brain/f8dd5efd-4ce8-499e-8359-ac13b3b2dd03/.system_generated/logs/transcript_full.jsonl new file mode 100644 index 000000000..78104b13d --- /dev/null +++ b/internal/sessions/testdata/agy-t3/brain/f8dd5efd-4ce8-499e-8359-ac13b3b2dd03/.system_generated/logs/transcript_full.jsonl @@ -0,0 +1,2 @@ +{"step_index":0,"source":"USER_EXPLICIT","type":"USER_INPUT","status":"DONE","created_at":"2026-11-19T01:06:24Z","content":"\nsay hi\n\n\nThe current local time is: 2026-11-19T09:06:24+08:00.\n\n\nThe user changed setting `Model Selection` from None to Gemini 3.1 Pro (Low). No need to comment on this change if the user doesn't ask about it. If reporting what model you are, please use a human readable name instead of the exact string.\n"} +{"step_index":1,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-11-19T01:06:24Z","model":"gemini-3.1-pro-low","input_tokens":1034,"cache_read_tokens":200,"output_tokens":56,"content":"hello from fake"}