-
-
Notifications
You must be signed in to change notification settings - Fork 39.6k
Description
Description
The usage dashboard (/usage in the control UI) only shows session data for the default ("main") agent. Sessions from other configured agents (e.g. news-agent, seq-monitor) are not included in the usage breakdown, even though their session transcripts contain valid usage/cost data.
Root Cause
In the sessions.usage RPC handler (gateway-cli-*.js), discoverAllSessions() is called without an agentId parameter:
const discoveredSessions = await discoverAllSessions({
startMs,
endMs
});The discoverAllSessions function resolves the sessions directory via resolveSessionTranscriptsDirForAgent(params?.agentId), which defaults to DEFAULT_AGENT_ID ("main") when no agentId is provided. This means it only scans ~/.openclaw/agents/main/sessions/.
Other agents' session JSONL files live in their own directories (e.g. ~/.openclaw/agents/news-agent/sessions/) and are never discovered.
Notably, loadCombinedSessionStoreForGateway() (called just above) does correctly iterate all configured agents and loads their session store entries. But since discoverAllSessions only walks the main agent's directory, the merge loop that follows only matches main-agent sessions.
Expected Behavior
The usage dashboard should aggregate session data across all configured agents, not just the default one. The Agent filter dropdown should list all agents that have session data.
Suggested Fix
discoverAllSessions should be called once per configured agent (from listConfiguredAgentIds(config)), or accept a list of agent IDs to scan:
const agentIds = listConfiguredAgentIds(config);
const allDiscovered = [];
for (const agentId of agentIds) {
const sessions = await discoverAllSessions({ agentId, startMs, endMs });
allDiscovered.push(...sessions);
}The same issue likely applies to sessions.usage.timeseries and sessions.usage.logs.
Environment
- OpenClaw version: 2026.2.6-3
- OS: Debian
- Config: 3 agents (main, news-agent, seq-monitor) with per-agent session directories
- Session store: Default (no custom
session.storepath configured)
Workaround
Manually query each agent's session JSONL files to calculate per-agent usage.