Skip to content

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

Keep context-only events out of the coverage join

Claudebe8a43bad110
diff --git a/cli/beacon/internal/tokens/coverage.go b/cli/beacon/internal/tokens/coverage.go
index 85cd9df3..8b73f705 100644
--- a/cli/beacon/internal/tokens/coverage.go
+++ b/cli/beacon/internal/tokens/coverage.go
@@ -228,6 +228,14 @@ func Coverage(events []schema.Event, installed []string) CoverageReport {
get(name).events++
}
for _, ue := range usageEvents {
+ if ue.contextOnly {
+ // The collector also yields events that reported only context occupancy. Those are
+ // not spend, so counting one here would mark a runtime covered on the strength of a
+ // number that never enters a total -- the precise false reassurance this report
+ // exists to prevent. Qwen Code is the live case: it reports how full its window was
+ // and never what a turn cost.
+ continue
+ }
name := asymptoteobserve.NormalizeHarnessName(strings.TrimSpace(ue.harness))
if name == "" {
continue
diff --git a/cli/beacon/internal/tokens/coverage_test.go b/cli/beacon/internal/tokens/coverage_test.go
index 5842d7b0..f1a06699 100644
--- a/cli/beacon/internal/tokens/coverage_test.go
+++ b/cli/beacon/internal/tokens/coverage_test.go
@@ -332,3 +332,35 @@ func TestInstalledRuntimesDeduplicatesAndNeedsOnlyOneManagedRow(t *testing.T) {
t.Fatalf("InstalledRuntimes = %v, want [claude_code vscode]", got)
}
}
+
+// The interaction between the two halves of this series. gen_ai.context events reach the shared
+// collector -- that is how the utilization report sees them -- so coverage would otherwise count
+// one as proof a runtime is reporting its spend. Qwen Code is the live case: it reports how full
+// its window was and never what a turn cost, so it must stay not_instrumented with zero usage
+// events. Counting occupancy as coverage would mark the one runtime whose spend Beacon cannot
+// read as fully covered, which is worse than saying nothing.
+func TestCoverageDoesNotCountContextOnlyEventsAsUsage(t *testing.T) {
+ events := []schema.Event{
+ usageEventFixture("2026-06-11T10:00:00Z", "qwen_code", "s1", "qwen3-coder-plus", func(e *schema.Event) {
+ e.GenAI.Usage = nil
+ e.GenAI.Context = &schema.GenAIContextInfo{
+ UsedTokens: int64Ptr(110100),
+ LimitTokens: int64Ptr(262144),
+ }
+ }),
+ }
+ report := Coverage(events, []string{"qwen_code"})
+ line := lineFor(t, report, "qwen_code")
+ if line.Status != CoverageNotInstrumented {
+ t.Errorf("status = %q, want not_instrumented", line.Status)
+ }
+ if line.UsageEvents != 0 {
+ t.Errorf("usage events = %d, want 0 -- context occupancy is not spend", line.UsageEvents)
+ }
+ if line.Tokens != 0 {
+ t.Errorf("tokens = %d, want 0", line.Tokens)
+ }
+ if report.Covered != 0 {
+ t.Errorf("covered = %d, want 0", report.Covered)
+ }
+}