mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 01:28:27 +00:00
fix(gateway): canonicalize main session aliases
This commit is contained in:
@@ -11,7 +11,6 @@ import {
|
||||
import { registerAgentRunContext } from "../../infra/agent-events.js";
|
||||
import { resolveOutboundTarget } from "../../infra/outbound/targets.js";
|
||||
import { DEFAULT_CHAT_PROVIDER } from "../../providers/registry.js";
|
||||
import { normalizeMainKey } from "../../routing/session-key.js";
|
||||
import { defaultRuntime } from "../../runtime.js";
|
||||
import { resolveSendPolicy } from "../../sessions/send-policy.js";
|
||||
import {
|
||||
@@ -29,7 +28,7 @@ import {
|
||||
validateAgentParams,
|
||||
validateAgentWaitParams,
|
||||
} from "../protocol/index.js";
|
||||
import { loadSessionEntry } from "../session-utils.js";
|
||||
import { loadSessionEntry, resolveSessionStoreKey } from "../session-utils.js";
|
||||
import { formatForLog } from "../ws-log.js";
|
||||
import { waitForAgentJob } from "./agent-job.js";
|
||||
import type { GatewayRequestHandlers } from "./types.js";
|
||||
@@ -190,24 +189,21 @@ export const agentHandlers: GatewayRequestHandlers = {
|
||||
return;
|
||||
}
|
||||
resolvedSessionId = sessionId;
|
||||
const agentId = resolveAgentIdFromSessionKey(requestedSessionKey);
|
||||
const mainSessionKey = resolveAgentMainSessionKey({
|
||||
const canonicalSessionKey = resolveSessionStoreKey({
|
||||
cfg,
|
||||
agentId,
|
||||
sessionKey: requestedSessionKey,
|
||||
});
|
||||
const rawMainKey = normalizeMainKey(cfg.session?.mainKey);
|
||||
// Normalize short main key alias to canonical form before store write
|
||||
const storeKey =
|
||||
requestedSessionKey === rawMainKey ? mainSessionKey : requestedSessionKey;
|
||||
const agentId = resolveAgentIdFromSessionKey(canonicalSessionKey);
|
||||
const mainSessionKey = resolveAgentMainSessionKey({ cfg, agentId });
|
||||
if (store) {
|
||||
store[storeKey] = nextEntry;
|
||||
store[canonicalSessionKey] = nextEntry;
|
||||
if (storePath) {
|
||||
await saveSessionStore(storePath, store);
|
||||
}
|
||||
}
|
||||
if (
|
||||
requestedSessionKey === mainSessionKey ||
|
||||
requestedSessionKey === rawMainKey
|
||||
canonicalSessionKey === mainSessionKey ||
|
||||
canonicalSessionKey === "global"
|
||||
) {
|
||||
context.addChatRun(idem, {
|
||||
sessionKey: requestedSessionKey,
|
||||
|
||||
Reference in New Issue
Block a user