Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix(fx): seed lastTotals from resume usage and advance cursor past future-schema lines

Cursor Agent7b1e1f4c9e36
diff --git a/cli/beacon/internal/fxsession/log.go b/cli/beacon/internal/fxsession/log.go
index bfa425e7..e211494e 100644
--- a/cli/beacon/internal/fxsession/log.go
+++ b/cli/beacon/internal/fxsession/log.go
@@ -91,6 +91,12 @@ func (d *Decoder) Next() (*Event, error) {
switch {
case errors.Is(err, ErrUnsupportedSchema):
d.stats.Skipped++
+ var env struct {
+ Seq uint64 `json:"seq"`
+ }
+ if json.Unmarshal(line, &env) == nil && env.Seq > d.stats.MaxSeq {
+ d.stats.MaxSeq = env.Seq
+ }
continue
case err != nil:
d.stats.Malformed++
diff --git a/cli/beacon/internal/fxsession/mapper.go b/cli/beacon/internal/fxsession/mapper.go
index 2d83b47a..76d0be42 100644
--- a/cli/beacon/internal/fxsession/mapper.go
+++ b/cli/beacon/internal/fxsession/mapper.go
@@ -120,11 +120,14 @@ func (m *mapper) consume(event *Event) {
m.workspace = root
}
m.applyPreferences(event.SessionStarted.Preferences)
- // A session_started can carry the usage the session resumed with. Seeding the delta
- // baseline from it stops the first checkpoint after a resume from being reported as if
- // the whole prior session had happened just then.
+ // A session_started can carry the usage the session resumed with. Seeding both delta
+ // baselines from it stops the first checkpoint and the first turn after a resume from
+ // being reported as if the whole prior session had happened just then.
if event.SessionStarted.Usage != nil {
m.lastUsage = event.SessionStarted.Usage
+ m.lastTotals.input = event.SessionStarted.Usage.InputTokens
+ m.lastTotals.output = event.SessionStarted.Usage.OutputTokens
+ m.lastTotals.seen = true
}
if emit && !m.opts.SkipSessionStarted {
m.emitSessionStarted(event)