mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 22:38:26 +00:00
fix(gateway): normalize session key to canonical form before store writes
Ensure 'main' alias is always stored as 'agent:main:main' to prevent duplicate entries. Also update loadSessionEntry to check both forms when looking up entries. Fixes duplicate main sessions in session store.
This commit is contained in:
@@ -189,12 +189,6 @@ export const agentHandlers: GatewayRequestHandlers = {
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (store) {
|
||||
store[requestedSessionKey] = nextEntry;
|
||||
if (storePath) {
|
||||
await saveSessionStore(storePath, store);
|
||||
}
|
||||
}
|
||||
resolvedSessionId = sessionId;
|
||||
const agentId = resolveAgentIdFromSessionKey(requestedSessionKey);
|
||||
const mainSessionKey = resolveAgentMainSessionKey({
|
||||
@@ -202,6 +196,15 @@ export const agentHandlers: GatewayRequestHandlers = {
|
||||
agentId,
|
||||
});
|
||||
const rawMainKey = normalizeMainKey(cfg.session?.mainKey);
|
||||
// Normalize short main key alias to canonical form before store write
|
||||
const storeKey =
|
||||
requestedSessionKey === rawMainKey ? mainSessionKey : requestedSessionKey;
|
||||
if (store) {
|
||||
store[storeKey] = nextEntry;
|
||||
if (storePath) {
|
||||
await saveSessionStore(storePath, store);
|
||||
}
|
||||
}
|
||||
if (
|
||||
requestedSessionKey === mainSessionKey ||
|
||||
requestedSessionKey === rawMainKey
|
||||
|
||||
Reference in New Issue
Block a user