-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem
Agent plugins that enrich token data from external sources (e.g. Cursor's CSV server export) have no way to signal to the core UI whether a session's data is estimated (local heuristic) or enriched (server-verified). The core renders all sessions identically, so users can't tell which token counts are approximate and which are accurate.
This came up building @tokentop/agent-cursor: sessions appear immediately with estimated tokens (text.length / 4), then get backfilled with accurate data from Cursor's server. During the gap, there's no visual distinction.
Proposed solution
Add an optional metadata field to SessionUsageData:
export interface SessionUsageData {
// ... existing fields ...
/**
* Optional plugin-defined metadata passed through to the core.
* Plugins can use this to signal data quality, enrichment status,
* or other plugin-specific information the UI may choose to render.
*
* Known keys (convention, not enforced):
* - `isEstimated` (boolean) — true when token counts are local estimates
*/
metadata?: Record<string, unknown>;
}This is a non-breaking, additive change. Existing plugins that don't set metadata are unaffected. The core decides how (or whether) to render metadata — plugins just expose the data.
Alternatives considered
- Prefix
sessionNamewith a marker (e.g."≈ Session Name") — hacky, mixes display concerns into data - Use absence of
cacheRead/cacheWriteas implicit signal — fragile, breaks for sessions that genuinely have no cache usage - Add a dedicated
isEstimatedboolean — too narrow;metadatabag is more extensible for future plugin needs
Area
Type definitions
Scope
Small (config, tweak, single type)
Additional context
Downstream issues:
- ttop: Propagate
metadatathroughAgentSessionAggregateand render an indicator inSessionsTable(separate issue) - agent-cursor: Set
metadata.isEstimatedinenrichWithCsvData()(will be implemented once SDK ships the type)
Implementation is ~3 lines in src/types/agent.ts. No runtime behavior change.