Skip to content

fix: pass agentId to resolveStorePath for correct multi-agent session store resolution#490

Closed
HarryLee1900 wants to merge 1 commit into
larksuite:mainfrom
HarryLee1900:fix/resolveStorePath-agentId
Closed

fix: pass agentId to resolveStorePath for correct multi-agent session store resolution#490
HarryLee1900 wants to merge 1 commit into
larksuite:mainfrom
HarryLee1900:fix/resolveStorePath-agentId

Conversation

@HarryLee1900
Copy link
Copy Markdown

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 the main agent's sessions.json.

Root Cause

resolveStorePath() in streaming-card-controller.ts is called without an agentId parameter. The OpenClaw runtime's resolveStorePath defaults to "main" when no agentId is provided. This means:

  • For agent cook, it tries to read agent:main:… entries from main's store
  • Cook's own entries are in agent:cook:… in cook's store
  • Cook finds nothing → footer shows no data

This 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:

  1. sessionApi.resolveStorePath() (runtime-provided in-memory store)
  2. channelSession.resolveStorePath() (filesystem fallback store)

Fix

Three changes in src/card/streaming-card-controller.ts:

  1. Extract agentId from session key: Parse the agent ID from this.deps.sessionKey (format: agent:<id>:…)
  2. Pass agentId to resolveStorePath: Both resolveStorePath() calls now receive { agentId: storeAgentId }
  3. Update TypeScript types: Inline type declarations for resolveStorePath now accept the optional opts parameter

This pattern is already used in src/card/tool-use-config.ts line 35:

const storePath = resolveStorePath(sessionStorePath, { agentId });

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 main showed empty footers. After applying the fix and restarting, all agents correctly display their own session metrics.

Related

  • The same bug was independently identified and a local workaround patch was applied. This PR upstreams the fix.

… 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.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 10, 2026

CLA assistant check
All committers have signed the CLA.

@evandance
Copy link
Copy Markdown
Collaborator

Thanks for the precise diagnosis and the targeted fix — the reuse of the tool-use-config.ts pattern is the right call, and the 10-agent production validation is appreciated.

CI is green now. Just need the CLA signed (link on this PR) and we're good to merge.

@evandance
Copy link
Copy Markdown
Collaborator

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 resolveStorePath call sites with the same fix direction. We got to #504 first in the review queue, so it's the version that landed in main — your work confirms the root cause independently, which raised confidence in the fix.

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.

@evandance evandance closed this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Multi-agent footer shows no session metrics for non-default agents

3 participants