Skip to content

Issue: Usage dashboard only discovers sessions from default (main) agent, ignoring other configured agents #11275

@Al3xand3r1987

Description

@Al3xand3r1987

Issue: Usage dashboard only discovers sessions from default (main) agent, ignoring other configured agents


Bug Description

The Usage dashboard (sessions.usage handler) only discovers session transcripts from the default main agent directory. Sessions belonging to other configured agents (e.g. opus) are completely missing from the usage overview.

Root Cause

In src/gateway/server-methods/usage.ts (~line 309), discoverAllSessions() is called without an agentId:

const discoveredSessions = await discoverAllSessions({
  startMs,
  endMs,
});

This causes resolveSessionTranscriptsDirForAgent(undefined)normalizeAgentId(undefined)DEFAULT_AGENT_ID = "main", so only agents/main/sessions/*.jsonl files are scanned.

Meanwhile, loadCombinedSessionStoreForGateway() correctly iterates over all configured agents via listConfiguredAgentIds() — so the session store knows about all agents, but the file discovery only looks in one directory.

Steps to Reproduce

  1. Configure multiple agents in openclaw.json:
{
  "agents": {
    "list": [
      { "id": "main", "model": { "primary": "..." } },
      { "id": "opus", "model": { "primary": "anthropic/claude-opus-4-6" } }
    ]
  }
}
  1. Use both agents (e.g. via channel bindings)
  2. Open the Usage dashboard → Agent filter only shows "main"
  3. Sessions from the second agent are invisible in usage tracking

Expected Behavior

All configured agents should appear in the Usage dashboard. The discovery should scan transcript directories for every agent in agents.list.

Suggested Fix

Replace the single-agent discovery call with a multi-agent scan:

// Current (broken):
const discoveredSessions = await discoverAllSessions({ startMs, endMs });

// Fix: discover from all configured agents
const agentIds = (config.agents?.list ?? []).map(a => a.id).filter(Boolean);
if (!agentIds.includes("main")) agentIds.unshift("main");

const discoveredSessions = (
  await Promise.all(
    agentIds.map((id) => discoverAllSessions({ agentId: id, startMs, endMs }))
  )
).flat();

Note: discoverAllSessions already accepts an optional agentId parameter and passes it through to resolveSessionTranscriptsDirForAgent — the plumbing is there, it just isn't being used.

Environment

  • OpenClaw version: 2026.2.6
  • Config: 2 agents (main + opus) with separate workspaces and channel bindings
  • Transcript files confirmed present in both agents/main/sessions/ and agents/opus/sessions/

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions