# avoid token profile percentage overflow

`ddcc916` · peyton-alt · 3w ago · 2 files · +16 added/-1 removed

## Sessions

1bbc15069665 View transcript

## Changes

2

- cmd/entire/cli

- Mtokens_profile.go +1/-1

- Mtokens_profile_test.go +15

```
229 unmodified lines

230
231
232
233
233
234
235
236

229 unmodified lines

if tokens.APICalls >= 20 {
		addTokensProfileSignal(signals, "api-call-amplification", checkpointID, denominator)
	}
	if tokens.Total > 0 && tokens.SubagentTotal*100 >= tokens.Total*10 {
		if tokenShareAtLeastOneTenth(tokens.SubagentTotal, tokens.Total) {
			addTokensProfileSignal(signals, "subagent-heavy", checkpointID, denominator)
		}
	}
```

Mcmd/entire/cli/tokens_profile.go +1/-1

```
13 unmodified lines

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

13 unmodified lines

"github.com/entireio/cli/redact"
}

func TestAddTokensProfileTokenSignalsSubagentHeavyAvoidsOverflow(t *testing.T) {

t.Parallel()

maxInt := int(^uint(0) >> 1)
	signals := map[string]*tokensProfileSignal{}
	addTokensProfileTokenSignals(signals, id.MustCheckpointID("999aaa000001"), &sessionTokensUsage{
		Total:         maxInt,
		SubagentTotal: maxInt,
	}, 1)

if signals["subagent-heavy"] == nil {
		t.Fatalf("expected subagent-heavy signal, got %+v", signals)
	}
}

func TestTokensProfileCmd_TextOutputAggregatesCommittedCheckpoints(t *testing.T) {
	repo, _ := runExplainAutoTestRepo(t)
	ctx := context.Background()
```

Mcmd/entire/cli/tokens_profile_test.go +15
