fix: pass agentId to resolveStorePath for correct multi-agent session store resolution#490
Conversation
… store resolution
In multi-agent setups, resolveStorePath() defaults to the 'main' agent's
sessions.json when called without an agentId. This causes non-main agents
to fail looking up their session metrics (footer shows no data).
Fix:
- Extract agentId from the session key (agent:<id>:…)
- Pass { agentId: storeAgentId } to both resolveStorePath() calls
(sessionApi and channelSession paths)
- Update inline type declarations for the opts parameter
This mirrors the pattern already used in tool-use-config.ts.
|
Thanks for the precise diagnosis and the targeted fix — the reuse of the CI is green now. Just need the CLA signed (link on this PR) and we're good to merge. |
|
Thanks for tracking this down across 10 agents in production, and for filing the issue (#494) and PR together — that's the right shape for a contribution. This was independently filed and reviewed in #504 (merged on 2026-05-13). Both PRs target the same Closing this in favor of #504, and #494 can be closed as resolved as well. Apologies for the parallel work — really appreciate the effort here. |
Problem
In multi-agent OpenClaw setups, the streaming card footer fails to display session metrics (token counts, model info, etc.) for non-default agents. The footer shows no data because
getFooterSessionMetrics()resolves all agents to themainagent'ssessions.json.Root Cause
resolveStorePath()instreaming-card-controller.tsis called without anagentIdparameter. The OpenClaw runtime'sresolveStorePathdefaults to"main"when noagentIdis provided. This means:cook, it tries to readagent:main:…entries frommain's storeagent:cook:…in cook's storeThis only manifests in multi-agent deployments. Single-agent setups (where the default agent IS
"main") work fine because the default matches reality.The same bug exists for both code paths:
sessionApi.resolveStorePath()(runtime-provided in-memory store)channelSession.resolveStorePath()(filesystem fallback store)Fix
Three changes in
src/card/streaming-card-controller.ts:this.deps.sessionKey(format:agent:<id>:…)resolveStorePath()calls now receive{ agentId: storeAgentId }resolveStorePathnow accept the optionaloptsparameterThis pattern is already used in
src/card/tool-use-config.tsline 35:Testing
Verified on a production OpenClaw deployment with 10 agents (main, cook, margaret, zhangxiaolong, jobs, jonathan, wangyangming, jiamu, buffett, turing). Before this fix, all agents except
mainshowed empty footers. After applying the fix and restarting, all agents correctly display their own session metrics.Related