fix(gateway): resolve identity.get session agent via config default

This commit is contained in:
root 2026-02-18 05:01:24 +00:00
parent bc50708057
commit ac6e8a0d81

View File

@ -1,5 +1,5 @@
import { randomUUID } from "node:crypto";
import { listAgentIds } from "../../agents/agent-scope.js";
import { listAgentIds, resolveSessionAgentId } from "../../agents/agent-scope.js";
import { BARE_SESSION_RESET_PROMPT } from "../../auto-reply/reply/session-reset-prompt.js";
import { agentCommand } from "../../commands/agent.js";
import { loadConfig } from "../../config/config.js";
@ -680,6 +680,7 @@ export const agentHandlers: GatewayRequestHandlers = {
const agentIdRaw = typeof p.agentId === "string" ? p.agentId.trim() : "";
const sessionKeyRaw = typeof p.sessionKey === "string" ? p.sessionKey.trim() : "";
let agentId = agentIdRaw ? normalizeAgentId(agentIdRaw) : undefined;
const cfg = loadConfig();
if (sessionKeyRaw) {
if (classifySessionKeyShape(sessionKeyRaw) === "malformed_agent") {
respond(
@ -692,7 +693,7 @@ export const agentHandlers: GatewayRequestHandlers = {
);
return;
}
const resolved = resolveAgentIdFromSessionKey(sessionKeyRaw);
const resolved = resolveSessionAgentId({ sessionKey: sessionKeyRaw, config: cfg });
if (agentId && resolved !== agentId) {
respond(
false,
@ -706,7 +707,6 @@ export const agentHandlers: GatewayRequestHandlers = {
}
agentId = resolved;
}
const cfg = loadConfig();
const identity = resolveAssistantIdentity({ cfg, agentId });
const avatarValue =
resolveAssistantAvatarUrl({