# avoid token profile percentage overflow

`3820c00`·

peyton-alt·3w ago·3 files·+17 added/-2 removed

## Sessions

1bbc15069665View transcript

[?\
okay proceedCodex·GPT-5.5·1 step](/content/gh/entireio/cli/session/019ed29b-5de8-7272-9e6c-89a843c92842#timeline-1bbc15069665/index.html)

## Changes

3

- cmd/entire/cli

- Mcheckpoint_tokens.go+1/-1

- Mtokens_profile.go+1/-1

- Mtokens_profile_test.go+15

```
443 unmodified lines

444
445
446
447
447
448
449
450

443 unmodified lines

Direction: checkpointDeltaDirection(change),
	}
	if baseline != 0 {
		percent := float64(delta.Change) * 100 / float64(baseline)
		percent := (float64(delta.Change) / float64(baseline)) * 100
		delta.ChangePercent = &percent
	}
	return delta
```

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

```
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()
```
