refactor: remove unused session alias argument (#161135)

* refactor: remove unused session alias argument

* test(gateway): show heartbeat follow-up failure context
This commit is contained in:
Peter Steinberger 2026-10-01 06:05:51 -07:00 • committed by GitHub
parent 7dd6ab7ac9
commit 6010d074f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 35 additions and 83 deletions

View file

@ -37,8 +37,8 @@ function resolveCodeModeRequesterSessionKey(ctx: ToolSearchToolContext): string
if (!sessionKey) {
throw new ToolInputError("code mode swarm globals require session and run identity.");
}
const { mainKey, alias } = resolveMainSessionAlias(ctx.runtimeConfig ?? ctx.config ?? {});
return resolveInternalSessionKey({ key: sessionKey, alias, mainKey });
const { alias } = resolveMainSessionAlias(ctx.runtimeConfig ?? ctx.config ?? {});
return resolveInternalSessionKey({ key: sessionKey, alias });
}
function resolveCodeModeSwarmGroupId(ctx: ToolSearchToolContext): string {

View file

@ -80,12 +80,8 @@ export async function buildActiveSubagentRuntimeContext(params: {
if (!rawControllerSessionKey) {
return undefined;
}
const { mainKey, alias } = resolveMainSessionAlias(params.cfg);
const controllerSessionKey = resolveInternalSessionKey({
key: rawControllerSessionKey,
alias,
mainKey,
});
const { alias } = resolveMainSessionAlias(params.cfg);
const controllerSessionKey = resolveInternalSessionKey({ key: rawControllerSessionKey, alias });
const agentId = params.controllerAgentId ?? parseAgentSessionKey(controllerSessionKey)?.agentId;
if (!agentId) {
return undefined;

View file

@ -51,13 +51,9 @@ export function resolveSubagentControllerIdentity(params: {
agentSessionKey?: string;
agentId?: string;
}): Omit<ResolvedSubagentController, "controlScope"> {
const { mainKey, alias } = resolveMainSessionAlias(params.cfg);
const { alias } = resolveMainSessionAlias(params.cfg);
const callerRaw = params.agentSessionKey?.trim() || alias;
const callerSessionKey = resolveInternalSessionKey({
key: callerRaw,
alias,
mainKey,
});
const callerSessionKey = resolveInternalSessionKey({ key: callerRaw, alias });
const controllerAgentId = resolveSessionAgentId({
config: params.cfg,
sessionKey: callerSessionKey,

View file

@ -77,14 +77,10 @@ export function resolveRequesterInternalSessionKey(params: {
cfg: OpenClawConfig;
requesterSessionKey?: string;
}): string {
const { mainKey, alias } = resolveMainSessionAlias(params.cfg);
const { alias } = resolveMainSessionAlias(params.cfg);
const requesterSessionKey = normalizeOptionalString(params.requesterSessionKey);
return requesterSessionKey
? resolveInternalSessionKey({
key: requesterSessionKey,
alias,
mainKey,
})
? resolveInternalSessionKey({ key: requesterSessionKey, alias })
: alias;
}

View file

@ -13,19 +13,11 @@ export function resolveSubagentSpawnOwnership(params: {
}) {
const { mainKey, alias } = resolveMainSessionAlias(params.cfg);
const controllerSessionKey = params.agentSessionKey
? resolveInternalSessionKey({
key: params.agentSessionKey,
alias,
mainKey,
})
? resolveInternalSessionKey({ key: params.agentSessionKey, alias })
: alias;
const completionOwnerKey = params.completionOwnerKey?.trim();
const completionRequesterSessionKey = completionOwnerKey
? resolveInternalSessionKey({
key: completionOwnerKey,
alias,
mainKey,
})
? resolveInternalSessionKey({ key: completionOwnerKey, alias })
: controllerSessionKey;
// Completion ownership can differ from control ownership when a parent proxies the spawn.
const completionRequesterDisplayKey = resolveDisplaySessionKey({

View file

@ -65,14 +65,10 @@ export function createAgentsListTool(opts?: {
outputSchema: AgentsListOutputSchema,
execute: async () => {
const cfg = getRuntimeConfig();
const { mainKey, alias } = resolveMainSessionAlias(cfg);
const { alias } = resolveMainSessionAlias(cfg);
const requesterInternalKey =
typeof opts?.agentSessionKey === "string" && opts.agentSessionKey.trim()
? resolveInternalSessionKey({
key: opts.agentSessionKey,
alias,
mainKey,
})
? resolveInternalSessionKey({ key: opts.agentSessionKey, alias })
: alias;
const requesterAgentId = resolveSessionAgentIds({
config: cfg,

View file

@ -51,8 +51,8 @@ export async function buildReminderContextLines(params: {
return [];
}
const cfg = getRuntimeConfig();
const { mainKey, alias } = resolveMainSessionAlias(cfg);
const resolvedKey = resolveInternalSessionKey({ key: sessionKey, alias, mainKey });
const { alias } = resolveMainSessionAlias(cfg);
const resolvedKey = resolveInternalSessionKey({ key: sessionKey, alias });
try {
const res = await params.callGatewayTool<{ messages: Array<unknown> }>(
"chat.history",

View file

@ -490,9 +490,9 @@ export function createCronTool(opts?: CronToolOptions, deps?: CronToolDeps): Any
: opts?.creatorToolAllowlistCaptureRef;
capCronJobToolsAllowOnCreate(job, creatorToolAllowlist);
assertInheritedCronToolCaptureReady(job, creatorToolAllowlistCaptureRef);
const { mainKey, alias } = resolveMainSessionAlias(runtimeConfig);
const { alias } = resolveMainSessionAlias(runtimeConfig);
const resolvedSessionKey = opts?.agentSessionKey
? resolveInternalSessionKey({ key: opts.agentSessionKey, alias, mainKey })
? resolveInternalSessionKey({ key: opts.agentSessionKey, alias })
: undefined;
const sessionTarget = normalizeLowercaseStringOrEmpty(job.sessionTarget);
if (!("sessionKey" in job) && resolvedSessionKey && sessionTarget !== "isolated") {
@ -678,11 +678,11 @@ export function createCronTool(opts?: CronToolOptions, deps?: CronToolDeps): Any
: "next-heartbeat";
// An omitted target wakes the originating conversation, not the
// heartbeat lane. Gateway owns target validation and authorization.
const { mainKey, alias } = resolveMainSessionAlias(runtimeConfig);
const { alias } = resolveMainSessionAlias(runtimeConfig);
const explicitSessionKey = readToolStringParam(params, "sessionKey");
const explicitAgentId = readToolStringParam(params, "agentId");
const inferredSessionKey = opts?.agentSessionKey
? resolveInternalSessionKey({ key: opts.agentSessionKey, alias, mainKey })
? resolveInternalSessionKey({ key: opts.agentSessionKey, alias })
: undefined;
const sessionKey = explicitSessionKey ?? inferredSessionKey;
// Pair an explicit session with its own agent; caller defaults must

View file

@ -27,7 +27,6 @@ export function resolveSessionStatusEntry(params: {
const internal = resolveInternalSessionKey({
key: keyRaw,
alias: params.alias,
mainKey: params.mainKey,
requesterInternalKey: params.requesterInternalKey,
});

View file

@ -330,11 +330,7 @@ export function resolveSandboxedSessionToolContext(params: {
const visibility = resolveSandboxSessionToolsVisibility(params.cfg);
const requesterSessionKey = normalizeOptionalString(params.agentSessionKey);
const requesterInternalKey = requesterSessionKey
? resolveInternalSessionKey({
key: requesterSessionKey,
alias,
mainKey,
})
? resolveInternalSessionKey({ key: requesterSessionKey, alias })
: undefined;
const effectiveRequesterKey = requesterInternalKey ?? alias;
const restrictToSpawned =

View file

@ -515,20 +515,12 @@ export function createSessionsListTool(opts?: {
updatedAt: typeof row.updatedAt === "number" ? row.updatedAt : 0,
},
sessionId,
sessionKey: resolveInternalSessionKey({
key,
alias,
mainKey,
}),
sessionKey: resolveInternalSessionKey({ key, alias }),
agentId: resolvedAgentId,
});
}
if (messageLimit > 0) {
const resolvedKey = resolveInternalSessionKey({
key,
alias,
mainKey,
});
const resolvedKey = resolveInternalSessionKey({ key, alias });
historyTargets.push({ row, resolvedKey });
}
rows.push(row);

View file

@ -97,12 +97,10 @@ describe("session key display/internal mapping", () => {
});
it("maps input main to alias for internal routing", () => {
expect(resolveInternalSessionKey({ key: "main", alias: "global", mainKey: "main" })).toBe(
"global",
expect(resolveInternalSessionKey({ key: "main", alias: "global" })).toBe("global");
expect(resolveInternalSessionKey({ key: "agent:ops:main", alias: "global" })).toBe(
"agent:ops:main",
);
expect(
resolveInternalSessionKey({ key: "agent:ops:main", alias: "global", mainKey: "main" }),
).toBe("agent:ops:main");
});
it("maps current to requester session key", () => {
@ -110,16 +108,13 @@ describe("session key display/internal mapping", () => {
resolveInternalSessionKey({
key: "current",
alias: "global",
mainKey: "main",
requesterInternalKey: "agent:support:main",
}),
).toBe("agent:support:main");
});
it("preserves literal current when no requester key is provided", () => {
expect(resolveInternalSessionKey({ key: "current", alias: "global", mainKey: "main" })).toBe(
"current",
);
expect(resolveInternalSessionKey({ key: "current", alias: "global" })).toBe("current");
});
it("maps interactive client ids to the requester session", () => {

View file

@ -51,7 +51,6 @@ export function resolveDisplaySessionKey(params: { key: string; alias: string; m
export function resolveInternalSessionKey(params: {
key: string;
alias: string;
mainKey: string;
requesterInternalKey?: string;
}) {
if (params.key === "current") {
@ -370,7 +369,6 @@ export async function resolveSessionReference(params: {
const resolvedKey = resolveInternalSessionKey({
key: raw,
alias: params.alias,
mainKey: params.mainKey,
requesterInternalKey: params.requesterInternalKey,
});
const semanticAliasAgentId =

View file

@ -149,8 +149,8 @@ function normalizeRequesterSessionKey(
if (!cleaned) {
return undefined;
}
const { mainKey, alias } = resolveMainSessionAlias(cfg);
return resolveInternalSessionKey({ key: cleaned, alias, mainKey });
const { alias } = resolveMainSessionAlias(cfg);
return resolveInternalSessionKey({ key: cleaned, alias });
}
export async function stopSubagentsForRequester(params: {

View file

@ -98,8 +98,8 @@ export function resolveRequesterSessionKey(
if (!raw) {
return undefined;
}
const { mainKey, alias } = resolveMainSessionAlias(params.cfg);
return resolveInternalSessionKey({ key: raw, alias, mainKey });
const { alias } = resolveMainSessionAlias(params.cfg);
return resolveInternalSessionKey({ key: raw, alias });
}
export function buildSubagentsHelp() {

View file

@ -48,8 +48,8 @@ function resolveSteerSourceSessionKey(params: {
return undefined;
}
const { mainKey, alias } = resolveMainSessionAlias(params.cfg);
return resolveInternalSessionKey({ key: raw, alias, mainKey });
const { alias } = resolveMainSessionAlias(params.cfg);
return resolveInternalSessionKey({ key: raw, alias });
}
/**

View file

@ -158,12 +158,8 @@ describe("parent Swarm outcome projection", () => {
cfg: globalConfig,
sessionKey: `agent:other:${suffix}`,
});
const { alias, mainKey } = resolveMainSessionAlias(globalConfig);
const requesterKey = resolveInternalSessionKey({
key: admitted.canonicalKey,
alias,
mainKey,
});
const { alias } = resolveMainSessionAlias(globalConfig);
const requesterKey = resolveInternalSessionKey({ key: admitted.canonicalKey, alias });
expect(requesterKey).toBe(suffix === "global" ? "agent:other:global" : "global");
await withCollectors(
[

View file

@ -477,8 +477,8 @@ export async function buildStatusReplyParts(
let subagentsLine: string | undefined;
if (sessionKey) {
const { mainKey, alias } = resolveMainSessionAlias(cfg);
const requesterKey = resolveInternalSessionKey({ key: sessionKey, alias, mainKey });
const { alias } = resolveMainSessionAlias(cfg);
const requesterKey = resolveInternalSessionKey({ key: sessionKey, alias });
const { buildControlledSubagentRunsReadContext, buildSubagentsStatusLine } =
await loadStatusSubagentsRuntime();
const subagentReadContext = await buildControlledSubagentRunsReadContext(