sessions: agy's own calls name the model its conversation database names (DvnT662 on X)
Usage → Requests showed every call read from a local agy-cli session with no model (v0.1.3996). The calls reader read only agy's transcript, brain/<id>/.system_generated/logs/transcript_full.jsonl, which carries tokens but no model. agy keeps the model in conversations/<id>.db, the Antigravity app's layout: gen_metadata field 1.19 is the served model, and a step's metadata field 20.3 names its generator (0 when left out, as antigravityRead reads it). A generator's "last_step_index" n in 1.20 names step n+1 for steps the steps table doesn't hold. - calls_agy.go: agyStepModels reads the db read-only and gives each transcript step its model (through agAppModel, so -n deployment suffixes go as on the app's rows). The call file's stat folds in the db and its -wal, so a model written after the step is read again. - agy.go: the Sessions page counts each step's tokens under that model (still "agy" when the db names none), and its rev folds in the db too. - parseVersions / callParseVersions "agy": 1, so cached parses are redone. Fixture: gen 0 is parkavenue9639's real agy 1.5.6 gen_metadata row from #3147 (matching its transcript step 1, 11519 in / 781 out); steps.tsv is the real steps.metadata agy 1.5.7 wrote on this Mac. Generator 1 is made in the test. Run (mote): go test -count=1 ./internal/sessions ./internal/usage ok; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok; gofmt -l clean. Broken by hand, each red: calls given no model; no last_step_index fallback; Sessions not moving counted tokens to the model; call files ignoring the db's stat; Sessions rev ignoring the db. Not tried: a live successful agy turn (this Mac's only agy account is refused, so its db has no answered step); agy in WSL; conversations with a db and no transcript still count nothing (#5432); tok/s and stripping -trial (#4805). Refs #3147, #4805, #5432
This commit is contained in:
+56
-12
@@ -41,9 +41,10 @@ import (
|
||||
// preview (what the app lists the conversation as: the user's own words
|
||||
// until it has a title, the title after) and workspace_uris, a JSON list
|
||||
// of file:// URIs. The Antigravity app's language server is agy's, and
|
||||
// keeps the same database in its own data folder (antigravity_app.go). The steps name no model, so
|
||||
// a conversation's tokens are counted under "agy", as its calls are left
|
||||
// with no model. `agy --conversation <id>` picks one up again, from any
|
||||
// keeps the same database in its own data folder (antigravity_app.go). The steps name no model:
|
||||
// a conversation's tokens are counted under the model its database,
|
||||
// conversations/<id>.db, names for each step (agyStepModels), as its calls
|
||||
// are, and under "agy" when it names none. `agy --conversation <id>` picks one up again, from any
|
||||
// folder; started on magpie's gateway, it needs the variables and --model
|
||||
// the agent's row gives (AgyStart).
|
||||
|
||||
@@ -229,9 +230,20 @@ func agyFilesIn(dir string) []file {
|
||||
for i := range out {
|
||||
id := strings.TrimPrefix(out[i].key, "agy:")
|
||||
has[id] = true
|
||||
rev := ""
|
||||
if r, ok := rows[id]; ok {
|
||||
out[i].w().agy = &r
|
||||
out[i].w().rev = agyRev(r)
|
||||
rev = agyRev(r)
|
||||
}
|
||||
// the conversation's database names its steps' models, and may
|
||||
// be written after the transcript
|
||||
for _, p := range agyDBFiles(out[i].path) {
|
||||
if fi, err := os.Stat(p); err == nil {
|
||||
rev += "\x00" + strconv.FormatInt(fi.ModTime().UnixNano(), 10) + ":" + strconv.FormatInt(fi.Size(), 10)
|
||||
}
|
||||
}
|
||||
if rev != "" {
|
||||
out[i].w().rev = rev
|
||||
}
|
||||
}
|
||||
for id, r := range rows {
|
||||
@@ -285,12 +297,23 @@ type agyCarry struct {
|
||||
type agyCounted struct {
|
||||
Date string `json:"d"`
|
||||
Tokens Tokens `json:"t"`
|
||||
// Model is the model the step's tokens are counted under, "" for
|
||||
// agyModel
|
||||
Model string `json:"m,omitempty"`
|
||||
}
|
||||
|
||||
// agyModel is the name a conversation's tokens are counted under: agy's
|
||||
// steps name no model.
|
||||
// agyModel is the name a step's tokens are counted under when its
|
||||
// conversation's database names no model for it.
|
||||
const agyModel = "agy"
|
||||
|
||||
// agyModelOr is the name a step of model m is counted under.
|
||||
func agyModelOr(m string) string {
|
||||
if m == "" {
|
||||
return agyModel
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
// parseAgy reads a transcript, on from where the read before left off when
|
||||
// the file has only grown (agy appends a step at a time).
|
||||
func parseAgy(f file, old *state) *state {
|
||||
@@ -320,10 +343,29 @@ func parseAgy(f file, old *state) *state {
|
||||
} else {
|
||||
s = &state{}
|
||||
}
|
||||
// the database is read once a read has a model's step to count
|
||||
var models map[int]string
|
||||
read := false
|
||||
model := func(step int) string {
|
||||
if !read {
|
||||
models, read = agyStepModels(agyConversationDB(f.path)), true
|
||||
}
|
||||
return models[step]
|
||||
}
|
||||
end, err := scanAt(f.path, off, nil, func(b []byte, _, _ int64) bool {
|
||||
agyCount(s, &c, b)
|
||||
agyCount(s, &c, b, model)
|
||||
return true
|
||||
})
|
||||
// a model the database names after its step was counted (or a read
|
||||
// before this one counted under agyModel) moves the step's tokens
|
||||
for i, was := range c.Steps {
|
||||
if m := model(i); m != "" && m != was.Model {
|
||||
s.dropUse(was.Date, agyModelOr(was.Model), was.Tokens)
|
||||
s.use(was.Date, m, was.Tokens)
|
||||
was.Model = m
|
||||
c.Steps[i] = was
|
||||
}
|
||||
}
|
||||
c.Tail = nil
|
||||
if err == nil {
|
||||
c.Tail = markTail(f.path, end, 0, end)
|
||||
@@ -337,8 +379,9 @@ func parseAgy(f file, old *state) *state {
|
||||
return s
|
||||
}
|
||||
|
||||
// agyCount counts one step of a transcript.
|
||||
func agyCount(s *state, c *agyCarry, b []byte) {
|
||||
// agyCount counts one step of a transcript, under the model model names
|
||||
// for its index.
|
||||
func agyCount(s *state, c *agyCarry, b []byte, model func(int) string) {
|
||||
var l agyLine
|
||||
if json.Unmarshal(b, &l) != nil || l.Step == nil {
|
||||
return
|
||||
@@ -354,14 +397,15 @@ func agyCount(s *state, c *agyCarry, b []byte) {
|
||||
t.CacheRead = *l.CacheRead
|
||||
}
|
||||
if was, ok := c.Steps[i]; ok {
|
||||
s.dropUse(was.Date, agyModel, was.Tokens)
|
||||
s.dropUse(was.Date, agyModelOr(was.Model), was.Tokens)
|
||||
}
|
||||
if !t.zero() {
|
||||
if c.Steps == nil {
|
||||
c.Steps = map[int]agyCounted{}
|
||||
}
|
||||
c.Steps[i] = agyCounted{dateOf(at), t}
|
||||
s.use(dateOf(at), agyModel, t)
|
||||
m := model(i)
|
||||
c.Steps[i] = agyCounted{dateOf(at), t, m}
|
||||
s.use(dateOf(at), agyModelOr(m), t)
|
||||
} else {
|
||||
delete(c.Steps, i)
|
||||
}
|
||||
|
||||
@@ -68,7 +68,9 @@ const callCacheVersion = "calls-v15"
|
||||
// (gemini-4-argon-d) is its model's (GeminiDeployment).
|
||||
// zcode 3: a call names its session as a request does, without the sess_
|
||||
// prefix (zcodeBareID), so the gateway's record of it pairs with it.
|
||||
var callParseVersions = map[string]int{"antigravity": 1, "cindy": 1, "codex": 3, "zcode": 3}
|
||||
// agy 1: a call names the model its conversation's database names for its
|
||||
// step (agyStepModels).
|
||||
var callParseVersions = map[string]int{"agy": 1, "antigravity": 1, "cindy": 1, "codex": 3, "zcode": 3}
|
||||
|
||||
// CallCacheVersion is callCacheVersion and callParseVersions, for a cache
|
||||
// of what is made of the calls (usage's requests-v1.bin and heatmap): a
|
||||
|
||||
@@ -3,6 +3,8 @@ package sessions
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
@@ -11,6 +13,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
// Antigravity CLI's (agy's) calls (#2097, parkavenue9639: a call agy made
|
||||
@@ -30,11 +34,19 @@ import (
|
||||
// began, to the second. A transcript an older agy wrote has the same lines
|
||||
// without the token fields; they are left out, not counted as zero.
|
||||
//
|
||||
// The step names no model (a custom model's isn't anywhere in agy's files,
|
||||
// and settings.json's is only the one picked now), nor the account, so the
|
||||
// call is agy's with the model and provider unknown. A step agy sent through
|
||||
// magpie is the gateway's to count: usage's matcher pairs it with the
|
||||
// gateway's record by its tokens and time (agy sends no session header).
|
||||
// The step names no model, nor the account. The model is in the
|
||||
// conversation's database, conversations/<conversation id>.db beside
|
||||
// brain/, the layout the Antigravity app keeps (antigravity_app.go: agy's
|
||||
// language server is the app's): a step's metadata field 20.3 is its
|
||||
// generator's gen_metadata idx, and the generator's field 1.19 the served
|
||||
// model's id ("gemini-4-argon"; agy 1.5.6's real rows on #3147 and #4805).
|
||||
// A generator also names the step it answered in its field 1.20, a list of
|
||||
// {1 key, 2 value}: "last_step_index" n is step n+1, which stands when the
|
||||
// step's own row can't be read. A call whose model can't be read keeps
|
||||
// none (DvnT662 on X: Usage → Requests showed agy's own calls with no
|
||||
// model). The provider stays unknown. A step agy sent through magpie is
|
||||
// the gateway's to count: usage's matcher pairs it with the gateway's
|
||||
// record by its tokens and time (agy sends no session header).
|
||||
|
||||
// AgyDir is agy's data folder, ~/.gemini/antigravity-cli.
|
||||
func AgyDir() string {
|
||||
@@ -42,8 +54,141 @@ func AgyDir() string {
|
||||
return filepath.Join(home, ".gemini", "antigravity-cli")
|
||||
}
|
||||
|
||||
// agyCallFiles are each conversation's transcript_full.jsonl.
|
||||
func agyCallFiles() []file { return agyTranscripts(AgyDir()) }
|
||||
// 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.
|
||||
func agyCallFiles() []file {
|
||||
out := agyTranscripts(AgyDir())
|
||||
for i := range out {
|
||||
for _, p := range agyDBFiles(out[i].path) {
|
||||
if fi, err := os.Stat(p); err == nil {
|
||||
out[i].size += fi.Size()
|
||||
if fi.ModTime().After(out[i].mod.Time()) {
|
||||
out[i].mod = modOf(fi.ModTime())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// agyConversationDB is the database of the conversation whose transcript
|
||||
// is at transcript: <data folder>/conversations/<id>.db for
|
||||
// <data folder>/brain/<id>/.system_generated/logs/transcript_full.jsonl.
|
||||
func agyConversationDB(transcript string) string {
|
||||
conv := filepath.Dir(filepath.Dir(filepath.Dir(transcript)))
|
||||
return filepath.Join(filepath.Dir(filepath.Dir(conv)), "conversations", filepath.Base(conv)+".db")
|
||||
}
|
||||
|
||||
// agyDBFiles are the database of transcript's conversation and its
|
||||
// write-ahead log.
|
||||
func agyDBFiles(transcript string) []string {
|
||||
db := agyConversationDB(transcript)
|
||||
return []string{db, db + "-wal"}
|
||||
}
|
||||
|
||||
// agyStepModels is the model of each step of a conversation's database,
|
||||
// by the step's index; nil when the database can't be read.
|
||||
func agyStepModels(path string) map[int]string {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return nil
|
||||
}
|
||||
db, err := provider.OpenReadOnly(path)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer db.Close()
|
||||
tx, err := db.BeginTx(context.Background(), &sql.TxOptions{ReadOnly: true})
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer tx.Rollback()
|
||||
out := map[int]string{}
|
||||
gens := map[int64]string{}
|
||||
rows, err := tx.Query("SELECT idx, data FROM gen_metadata WHERE data IS NOT NULL")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
for rows.Next() {
|
||||
var idx int64
|
||||
var b []byte
|
||||
if rows.Scan(&idx, &b) != nil {
|
||||
continue
|
||||
}
|
||||
m := agAppModel(b)
|
||||
if m == "" {
|
||||
continue
|
||||
}
|
||||
gens[idx] = m
|
||||
if step, ok := agyGenStep(b); ok {
|
||||
out[step] = m
|
||||
}
|
||||
}
|
||||
rows.Close()
|
||||
rows, err = tx.Query("SELECT idx, metadata FROM steps WHERE metadata IS NOT NULL")
|
||||
if err != nil {
|
||||
return out
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
var idx int64
|
||||
var b []byte
|
||||
if rows.Scan(&idx, &b) != nil {
|
||||
continue
|
||||
}
|
||||
// a step's place names its generator, generator 0 by leaving it
|
||||
// out (as antigravityRead reads it)
|
||||
var gen int64
|
||||
if pbWalk(b, func(num int, v uint64, d []byte) {
|
||||
if num == 20 && d != nil {
|
||||
_ = pbWalk(d, func(n int, v uint64, d []byte) {
|
||||
if n == 3 && d == nil {
|
||||
gen = int64(v)
|
||||
}
|
||||
})
|
||||
}
|
||||
}) != nil {
|
||||
continue
|
||||
}
|
||||
if m, ok := gens[gen]; ok {
|
||||
out[int(idx)] = m
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// agyGenStep is the step a generator answered: its "last_step_index" n,
|
||||
// in field 1.20, is step n+1.
|
||||
func agyGenStep(b []byte) (int, bool) {
|
||||
step, ok := 0, false
|
||||
_ = pbWalk(b, func(num int, v uint64, d []byte) {
|
||||
if num != 1 || d == nil {
|
||||
return
|
||||
}
|
||||
_ = pbWalk(d, func(n int, v uint64, d []byte) {
|
||||
if n != 20 || d == nil {
|
||||
return
|
||||
}
|
||||
var key, val string
|
||||
_ = pbWalk(d, func(n int, v uint64, d []byte) {
|
||||
switch {
|
||||
case d == nil:
|
||||
case n == 1:
|
||||
key = string(d)
|
||||
case n == 2:
|
||||
val = string(d)
|
||||
}
|
||||
})
|
||||
if key == "last_step_index" {
|
||||
if i, err := strconv.Atoi(strings.TrimSpace(val)); err == nil && i >= 0 {
|
||||
step, ok = i+1, true
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
return step, ok
|
||||
}
|
||||
|
||||
type agyStep struct {
|
||||
Step *int `json:"step_index"`
|
||||
@@ -90,6 +235,13 @@ func readAgyCalls(f file) (*callFile, bool) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if len(at) > 0 {
|
||||
if models := agyStepModels(agyConversationDB(f.path)); len(models) > 0 {
|
||||
for step, i := range at {
|
||||
st.Calls[i].Model = models[step]
|
||||
}
|
||||
}
|
||||
}
|
||||
return st, true
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
package sessions
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
// agyModelConv is the conversation of testdata/agy-db.
|
||||
const agyModelConv = "7b4b53b1-0bb4-4391-b86e-680cea68e587"
|
||||
|
||||
// agyModelTranscript is a conversation's transcript: the user's step, the
|
||||
// model's step parkavenue9639 matched to the generator on #3147 (step 1,
|
||||
// 11519 in, 0 from the cache, 781 out), a tool's result, and a second
|
||||
// model's step.
|
||||
const agyModelTranscript = `{"step_index":0,"source":"USER_EXPLICIT","type":"USER_INPUT","status":"DONE","created_at":"2026-11-12T07:24:44Z","content":"<USER_REQUEST>\nlist the folder\n</USER_REQUEST>"}
|
||||
{"step_index":1,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-11-12T07:24:50Z","input_tokens":11519,"cache_read_tokens":0,"output_tokens":781,"tool_calls":[{"name":"run_command","args":{}}]}
|
||||
{"step_index":2,"source":"MODEL","type":"PLANNER_RESPONSE","status":"DONE","created_at":"2026-11-12T07:25:02Z","input_tokens":900,"cache_read_tokens":100,"output_tokens":40,"content":"Done."}
|
||||
`
|
||||
|
||||
// putAgyModelTranscript writes the transcript into agy's data folder under
|
||||
// a sandbox HOME, and gives that folder.
|
||||
func putAgyModelTranscript(t *testing.T) string {
|
||||
t.Helper()
|
||||
claude, _ := setup(t)
|
||||
dir := filepath.Join(filepath.Dir(claude), "home", ".gemini", "antigravity-cli")
|
||||
logs := filepath.Join(dir, "brain", agyModelConv, ".system_generated", "logs")
|
||||
if err := os.MkdirAll(logs, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(logs, "transcript_full.jsonl"), []byte(agyModelTranscript), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
Reset()
|
||||
return dir
|
||||
}
|
||||
|
||||
// putAgyModelDB writes the conversation's database, in WAL mode as agy
|
||||
// keeps it, in the layout agy 1.5.7 made on this Mac (the Antigravity
|
||||
// app's, antigravitySchema), from testdata/agy-db:
|
||||
//
|
||||
// - gen_metadata.tsv: generator 0, parkavenue9639's real agy 1.5.6 row
|
||||
// on #3147 (ids overwritten with x at the same length). Its field 1.19
|
||||
// is "gemini-4-argon", and its "last_step_index" "0" says it answered
|
||||
// step 1.
|
||||
// - steps.tsv: the two steps.metadata rows agy 1.5.7 wrote here (a
|
||||
// user's step, whose place names no generator, so 0; and a step placed
|
||||
// at generator 1), the second written as step 2.
|
||||
//
|
||||
// Generator 1 is made here: field 1.19 "gemini-3.8-flash-n", the
|
||||
// deployment name the Antigravity app's rows carry (#2190), with a
|
||||
// last_step_index that names no step of the transcript. Step 1 has no
|
||||
// steps row, so its generator's own last_step_index names its model.
|
||||
func putAgyModelDB(t *testing.T, dir string) {
|
||||
t.Helper()
|
||||
conv := filepath.Join(dir, "conversations")
|
||||
if err := os.MkdirAll(conv, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
db, err := sql.Open("sqlite", filepath.Join(conv, agyModelConv+".db")+"?_pragma=journal_mode(WAL)")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer db.Close()
|
||||
if _, err := db.Exec(antigravitySchema); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rows := func(name string) [][]byte {
|
||||
raw, err := os.ReadFile(filepath.Join("testdata", "agy-db", name))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var out [][]byte
|
||||
for _, line := range strings.Split(strings.TrimSpace(string(raw)), "\n") {
|
||||
_, h, _ := strings.Cut(line, "\t")
|
||||
b, err := hex.DecodeString(strings.TrimSpace(h))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
out = append(out, b)
|
||||
}
|
||||
return out
|
||||
}
|
||||
gen0 := rows("gen_metadata.tsv")[0]
|
||||
steps := rows("steps.tsv")
|
||||
field := func(n uint64, b []byte) []byte {
|
||||
out := binary.AppendUvarint(nil, n<<3|2)
|
||||
return append(binary.AppendUvarint(out, uint64(len(b))), b...)
|
||||
}
|
||||
kv := append(field(1, []byte("last_step_index")), field(2, []byte("40"))...)
|
||||
gen1 := field(1, append(field(19, []byte("gemini-3.8-flash-n")), field(20, kv)...))
|
||||
for i, g := range [][]byte{gen0, gen1} {
|
||||
if _, err := db.Exec("INSERT INTO gen_metadata (idx, data, size) VALUES (?, ?, ?)", i, g, len(g)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
for i, idx := range []int{0, 2} {
|
||||
if _, err := db.Exec("INSERT INTO steps (idx, step_type, metadata) VALUES (?, 15, ?)", idx, steps[i]); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func agyCallsNow() []Call {
|
||||
var got []Call
|
||||
for _, c := range Calls(time.Time{}) {
|
||||
if c.Agent == "agy" {
|
||||
got = append(got, c)
|
||||
}
|
||||
}
|
||||
slices.SortFunc(got, func(a, b Call) int { return a.Time.Compare(b.Time) })
|
||||
return got
|
||||
}
|
||||
|
||||
// DvnT662 on X (#3147, #4805): Usage → Requests showed agy's own calls
|
||||
// with no model. Each names the model its conversation's database names
|
||||
// for its step.
|
||||
func TestAgyCallsNameTheirModel(t *testing.T) {
|
||||
dir := putAgyModelTranscript(t)
|
||||
putAgyModelDB(t, dir)
|
||||
got := agyCallsNow()
|
||||
want := []struct {
|
||||
model string
|
||||
tokens Tokens
|
||||
}{
|
||||
{"gemini-4-argon", Tokens{Input: 11519, Output: 781}},
|
||||
{"gemini-3.8-flash", Tokens{Input: 900, CacheRead: 100, Output: 40}},
|
||||
}
|
||||
if len(got) != len(want) {
|
||||
t.Fatalf("want %d calls, got %d: %+v", len(want), len(got), got)
|
||||
}
|
||||
for i, w := range want {
|
||||
if got[i].Model != w.model || got[i].Tokens != w.tokens {
|
||||
t.Errorf("call %d: %q %+v, want %q %+v", i, got[i].Model, got[i].Tokens, w.model, w.tokens)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The database written after the transcript was read (agy writes its
|
||||
// generator's row as the step ends): the calls, and the session's tokens,
|
||||
// are read again under the model.
|
||||
func TestAgyModelWrittenLater(t *testing.T) {
|
||||
inZone(t, 0)
|
||||
dir := putAgyModelTranscript(t)
|
||||
for _, c := range agyCallsNow() {
|
||||
if c.Model != "" {
|
||||
t.Fatalf("no database yet, but call names %q", c.Model)
|
||||
}
|
||||
}
|
||||
s := find(t, List(0), "agy", agyModelConv)
|
||||
if m := model(s, "agy"); m.Tokens != (Tokens{Input: 12419, CacheRead: 100, Output: 821}) {
|
||||
t.Fatalf("before the database: %+v", s.Models)
|
||||
}
|
||||
|
||||
putAgyModelDB(t, dir)
|
||||
got := agyCallsNow()
|
||||
if len(got) != 2 || got[0].Model != "gemini-4-argon" || got[1].Model != "gemini-3.8-flash" {
|
||||
t.Fatalf("after the database: %+v", got)
|
||||
}
|
||||
s = find(t, List(0), "agy", agyModelConv)
|
||||
if m := model(s, "gemini-4-argon"); m.Tokens != (Tokens{Input: 11519, Output: 781}) {
|
||||
t.Fatalf("gemini-4-argon: %+v", s.Models)
|
||||
}
|
||||
if m := model(s, "gemini-3.8-flash"); m.Tokens != (Tokens{Input: 900, CacheRead: 100, Output: 40}) {
|
||||
t.Fatalf("gemini-3.8-flash: %+v", s.Models)
|
||||
}
|
||||
if m := model(s, "agy"); m.Tokens != (Tokens{}) {
|
||||
t.Fatalf("still counted under agy: %+v", s.Models)
|
||||
}
|
||||
}
|
||||
|
||||
// A database that isn't one (agy_manage_test's stand-in) names no model,
|
||||
// and the calls are read as before.
|
||||
func TestAgyUnreadableDB(t *testing.T) {
|
||||
dir := putAgyModelTranscript(t)
|
||||
conv := filepath.Join(dir, "conversations")
|
||||
os.MkdirAll(conv, 0o755)
|
||||
if err := os.WriteFile(filepath.Join(conv, agyModelConv+".db"), []byte("SQLite format 3\x00"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := agyCallsNow()
|
||||
if len(got) != 2 || got[0].Model != "" || got[1].Model != "" {
|
||||
t.Fatalf("%+v", got)
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func TestAgyCalls(t *testing.T) {
|
||||
t.Errorf("call %d: %v %s %+v, want %s %s %+v", i, c.Time, c.Session, c.Tokens, w.at, w.session, w.tokens)
|
||||
}
|
||||
if c.Model != "" {
|
||||
t.Errorf("call %d names model %q, which agy's step doesn't", i, c.Model)
|
||||
t.Errorf("call %d names model %q, with no database of its conversation", i, c.Model)
|
||||
}
|
||||
if c.Msg == "" {
|
||||
t.Errorf("call %d: no step id to count it once by", i)
|
||||
|
||||
@@ -1464,7 +1464,9 @@ const cacheVersion = 29
|
||||
// (a parse kept from before has none, under the same row revision).
|
||||
// dsh 3: the ids of its newest turn's messages (TurnConvs), which a
|
||||
// request still answering carried and has no reply id for yet.
|
||||
var parseVersions = map[string]int{"codex": 3, "zcode": 1, "dsh": 3, "antigravity": 2}
|
||||
// agy 1: a step's tokens are counted under the model its conversation's
|
||||
// database names (agyStepModels), not "agy".
|
||||
var parseVersions = map[string]int{"codex": 3, "zcode": 1, "dsh": 3, "antigravity": 2, "agy": 1}
|
||||
|
||||
type cacheFile struct {
|
||||
Version int `json:"version"`
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
0 1203010203222478787878787878787878787878787878787878787878787878787878787878787878787842df03c4d068889cb630a5c5c930f0b18f31f6b18f31f5e99531f8e99531fbcff23182d0f23193e3f431c1c8fd31bab28332bfb28332e2f78332edf78332b2b48932acc4ae32b3c4ae32d0edb032d3edb032f090b332f290b332b4dbb432b9dbb432f2eeb432d4d2b832e8edba32eaedba32a1f5ba32a4f5ba3283ffbc32cdd1bd32cfd1bd32c3ecbe32cfecbe32d1ecbe328ea5c23296a5c232fdbcc4328abdc4328bbdc432a0bdc432a1bdc432b6bdc432e0d4c632e5d4c632f7d4c632b886c732add9c732afd9c7329cd1c9329ed1c93291efcb32aeefcb32d5d6cc32ecd6cc32cda2cd32cfa2cd32f2a5ce32d4c1ce32e4d5d332d4efd532dff7d632fefcdc32aad4dd32acd4dd32b8d4dd32bad4dd328dfbe632acd1e732aed1e732c6b5e832c4b8e832eda7e932efa7e932f1a7e932f3a7e932f5a7e9329c95ea32acb4eb32aeb4eb32fce5ec32fee5ec32de85ed32e585ed32ec85ed32ef85ed3287fced3289fced3290fced3292fced32e897f132a4a2f132a6a2f132bff5f132a7bdf332d7e2f332b292f6328abdf632f4f4f632e5f6f632cf86f7328da4f732caf6f7329a8cf8329c8cf832c9a9f832cda9f832cea9f832cfa9f832decdf832daf1f832d6c0f932d0c7fc32c5c8fe32c7c8fe32a9d4ff32a0f48233b2f48233e4de83330abe0518890b227708890b10ff59188d0630183a287878787878787878787878787878787878787878787878787878787878787878787878787878787842210a0973657373696f6e494412147878787878787878787878787878787878787878489f0350ee025a1778787878787878787878787878787878787878787878784a1410ffffffffffffffffff01520708967f2080d00f5a08080b10a0cfc7d7036208080510839de9a7028a018b01127708890b10ff59188d0630183a287878787878787878787878787878787878787878787878787878787878787878787878787878787842210a0973657373696f6e494412147878787878787878787878787878787878787878489f0350ee025a1778787878787878787878787878787878787878787878782210787878787878787878787878787878789a010e67656d696e692d342d6172676f6ea201140a0b757365645f636c61756465120566616c7365a201210a18757365645f636c617564655f636f6e736572766174697665120566616c7365a201370a0f726f6f745f636173636164655f69641224787878787878787878787878787878787878787878787878787878787878787878787878a201350a0d7472616a6563746f72795f69641224787878787878787878787878787878787878787878787878787878787878787878787878a201140a0f6c6173745f737465705f696e646578120130a201340a0a726571756573745f696412267878787878787878787878787878787878787878787878787878787878787878787878787878a2011e0a15757365645f6e6f6e5f67656d696e695f6d6f64656c120566616c7365a201320a0a636173636164655f69641224787878787878787878787878787878787878787878787878787878787878787878787878a201240a0a6d6f64656c5f656e756d12164d4f44454c5f504c414345484f4c4445525f4d343137
|
||||
|
+2
@@ -0,0 +1,2 @@
|
||||
0 0A0C08BCD3D5D70610F0D899ED011804622465316536643335612D663061392D343039312D383866662D313264303065653761313464A2014C0A2430636639666133382D643031632D343037662D393366392D636239373631326265633238222437623462353362312D306262342D343339312D623836652D363830636561363865353837D201120A100803120C08BCD3D5D70610E8C6EEF8019A02206361613936383061633462333465656238663939643864353436623835396238
|
||||
1 0A0B08BDD3D5D70610B89993311805A201500A2430636639666133382D643031632D343037662D393366392D63623937363132626563323810011801222437623462353362312D306262342D343339312D623836652D363830636561363865353837D201110A0F0803120B08BDD3D5D70610A8C893319A02206630323533666439633366353430343839666235643063376235373361363439
|
||||
|
Reference in New Issue
Block a user