refactor: canonicalize gateway session store keys
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
|
||||
import { getAgentRunContext, registerAgentRunContext } from "../infra/agent-events.js";
|
||||
import { parseAgentSessionKey } from "../routing/session-key.js";
|
||||
import { toAgentRequestSessionKey } from "../routing/session-key.js";
|
||||
|
||||
export function resolveSessionKeyForRun(runId: string) {
|
||||
const cached = getAgentRunContext(runId)?.sessionKey;
|
||||
@@ -12,8 +12,7 @@ export function resolveSessionKeyForRun(runId: string) {
|
||||
const found = Object.entries(store).find(([, entry]) => entry?.sessionId === runId);
|
||||
const storeKey = found?.[0];
|
||||
if (storeKey) {
|
||||
const parsed = parseAgentSessionKey(storeKey);
|
||||
const sessionKey = parsed?.rest ?? storeKey;
|
||||
const sessionKey = toAgentRequestSessionKey(storeKey) ?? storeKey;
|
||||
registerAgentRunContext(runId, { sessionKey });
|
||||
return sessionKey;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user