# add API-only token brief guidance

`83b9330`→[main](/content/gh/entireio/cli/commits/main/index.html)·

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

## Sessions

210fe202c7caView transcript

## Changes

2

- cmd/entire/cli

- Msession_tokens.go+2

- Msessions_test.go+41

```
461 unmodified lines

462
463
464
465
466
467
468
469

461 unmodified lines

switch {
	case hasTokenRecommendation(report, "context-replay-hotspot") && hasTokenRecommendation(report, "api-call-amplification"):
		return "Summarize the useful findings, then batch the next diagnostic step. Avoid more exploratory reads until you have a narrowed hypothesis."
	case hasTokenRecommendation(report, "api-call-amplification"):
		return "Batch the next diagnostic step around one narrowed hypothesis before making more tool calls."
	case hasTokenRecommendation(report, "context-replay-hotspot"):
		return "Summarize the current useful findings before continuing, and keep the next prompt narrow."
	case hasTokenRecommendation(report, "no-token-data"):
```

Mcmd/entire/cli/session_tokens.go+2

```
1305 unmodified lines

1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352

1305 unmodified lines

}
}

func TestTokensCmd_AgentBriefHighAPICallsWithoutCacheReplay(t *testing.T) {
	setupStopTestRepo(t)

ctx := context.Background()
	state := makeSessionState("test-tokens-brief-api-only", session.PhaseActive)
	state.AgentType = testAgentClaude
	state.TokenUsage = &agent.TokenUsage{
		InputTokens:  10_000,
		OutputTokens: 1_000,
		APICallCount: 25,
	}

if err := strategy.SaveSessionState(ctx, state); err != nil {
		t.Fatalf("SaveSessionState() error = %v", err)
	}

cmd := newTokensCmd()
	var stdout bytes.Buffer
	cmd.SetOut(&stdout)
	cmd.SetArgs([]string{"test-tokens-brief-api-only", "--agent-brief"})

if err := cmd.ExecuteContext(ctx); err != nil {
		t.Fatalf("expected no error, got: %v", err)
	}

out := stdout.String()
	checks := []string{
		"Token usage: 11k total; 25 API calls.",
		"Batch the next diagnostic step around one narrowed hypothesis before making more tool calls.",
		"- API call count is high for one session.",
	}
	for _, check := range checks {
		if !strings.Contains(out, check) {
			t.Errorf("expected %q in output, got:\n%s", check, out)
		}
	}
	if strings.Contains(out, "Continue normally") {
		t.Fatalf("expected high API calls to avoid continue-normally action, got:\n%s", out)
	}
}

func TestTokensCmd_AgentBriefNoTokenData(t *testing.T) {
	setupStopTestRepo(t)
