fix openclaw gateway session key routing

This commit is contained in:
Shoaib Ansari
2026-03-30 12:13:39 +05:30
parent 6a72faf83b
commit 8e2148e99d
2 changed files with 67 additions and 4 deletions
@@ -126,16 +126,26 @@ function normalizeSessionKeyStrategy(value: unknown): SessionKeyStrategy {
return "issue";
}
function resolveSessionKey(input: {
function prefixSessionKeyForAgent(sessionKey: string, agentId: string | null): string {
if (!agentId || sessionKey.startsWith("agent:")) return sessionKey;
return `agent:${agentId}:${sessionKey}`;
}
export function resolveSessionKey(input: {
strategy: SessionKeyStrategy;
configuredSessionKey: string | null;
agentId: string | null;
runId: string;
issueId: string | null;
}): string {
const fallback = input.configuredSessionKey ?? "paperclip";
if (input.strategy === "run") return `paperclip:run:${input.runId}`;
if (input.strategy === "issue" && input.issueId) return `paperclip:issue:${input.issueId}`;
return fallback;
if (input.strategy === "run") {
return prefixSessionKeyForAgent(`paperclip:run:${input.runId}`, input.agentId);
}
if (input.strategy === "issue" && input.issueId) {
return prefixSessionKeyForAgent(`paperclip:issue:${input.issueId}`, input.agentId);
}
return prefixSessionKeyForAgent(fallback, input.agentId);
}
function isLoopbackHost(hostname: string): boolean {
@@ -1060,6 +1070,7 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
const sessionKey = resolveSessionKey({
strategy: sessionKeyStrategy,
configuredSessionKey,
agentId: nonEmpty(ctx.config.agentId),
runId: ctx.runId,
issueId: wakePayload.issueId,
});