mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
fix: prefer target entry for command system prompt
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { resolveSessionAgentIds } from "../../agents/agent-scope.js";
|
||||
import { resolveBootstrapContextForRun } from "../../agents/bootstrap-files.js";
|
||||
import { resolveSandboxRuntimeStatus } from "../../agents/sandbox.js";
|
||||
import type { HandleCommandsParams } from "./commands-types.js";
|
||||
|
||||
@@ -166,6 +167,44 @@ describe("resolveCommandsSystemPromptBundle", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("prefers the target session entry for bootstrap and tool metadata", async () => {
|
||||
const params = makeParams();
|
||||
params.sessionEntry = {
|
||||
sessionId: "wrapper-session",
|
||||
groupId: "wrapper-group",
|
||||
groupChannel: "#wrapper",
|
||||
space: "wrapper-space",
|
||||
spawnedBy: "agent:wrapper",
|
||||
};
|
||||
params.sessionStore = {
|
||||
"agent:target:telegram:direct:target-session": {
|
||||
sessionId: "target-session",
|
||||
groupId: "target-group",
|
||||
groupChannel: "#target",
|
||||
space: "target-space",
|
||||
spawnedBy: "agent:target-parent",
|
||||
},
|
||||
} as HandleCommandsParams["sessionStore"];
|
||||
params.sessionKey = "agent:target:telegram:direct:target-session";
|
||||
|
||||
const { resolveCommandsSystemPromptBundle } = await import("./commands-system-prompt.js");
|
||||
await resolveCommandsSystemPromptBundle(params);
|
||||
|
||||
expect(vi.mocked(resolveBootstrapContextForRun)).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
sessionId: "target-session",
|
||||
}),
|
||||
);
|
||||
expect(createOpenClawCodingToolsMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
groupId: "target-group",
|
||||
groupChannel: "#target",
|
||||
groupSpace: "target-space",
|
||||
spawnedBy: "agent:target-parent",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("uses the resolved session key and forwards full-access block reasons", async () => {
|
||||
const { resolveCommandsSystemPromptBundle } = await import("./commands-system-prompt.js");
|
||||
const sandboxRuntime = await import("../../agents/sandbox.js");
|
||||
|
||||
@@ -29,6 +29,7 @@ export async function resolveCommandsSystemPromptBundle(
|
||||
params: HandleCommandsParams,
|
||||
): Promise<CommandsSystemPromptBundle> {
|
||||
const workspaceDir = params.workspaceDir;
|
||||
const targetSessionEntry = params.sessionStore?.[params.sessionKey] ?? params.sessionEntry;
|
||||
const { sessionAgentId } = resolveSessionAgentIds({
|
||||
sessionKey: params.sessionKey,
|
||||
config: params.cfg,
|
||||
@@ -38,7 +39,7 @@ export async function resolveCommandsSystemPromptBundle(
|
||||
workspaceDir,
|
||||
config: params.cfg,
|
||||
sessionKey: params.sessionKey,
|
||||
sessionId: params.sessionEntry?.sessionId,
|
||||
sessionId: targetSessionEntry?.sessionId,
|
||||
});
|
||||
const sandboxRuntime = resolveSandboxRuntimeStatus({
|
||||
cfg: params.cfg,
|
||||
@@ -53,7 +54,7 @@ export async function resolveCommandsSystemPromptBundle(
|
||||
remote: getRemoteSkillEligibility({
|
||||
advertiseExecNode: canExecRequestNode({
|
||||
cfg: params.cfg,
|
||||
sessionEntry: params.sessionEntry,
|
||||
sessionEntry: targetSessionEntry,
|
||||
sessionKey: params.sessionKey,
|
||||
agentId: sessionAgentId,
|
||||
}),
|
||||
@@ -75,10 +76,10 @@ export async function resolveCommandsSystemPromptBundle(
|
||||
sessionKey: params.sessionKey,
|
||||
allowGatewaySubagentBinding: true,
|
||||
messageProvider: params.command.channel,
|
||||
groupId: params.sessionEntry?.groupId ?? undefined,
|
||||
groupChannel: params.sessionEntry?.groupChannel ?? undefined,
|
||||
groupSpace: params.sessionEntry?.space ?? undefined,
|
||||
spawnedBy: params.sessionEntry?.spawnedBy ?? undefined,
|
||||
groupId: targetSessionEntry?.groupId ?? undefined,
|
||||
groupChannel: targetSessionEntry?.groupChannel ?? undefined,
|
||||
groupSpace: targetSessionEntry?.space ?? undefined,
|
||||
spawnedBy: targetSessionEntry?.spawnedBy ?? undefined,
|
||||
senderId: params.command.senderId,
|
||||
senderName: params.ctx.SenderName,
|
||||
senderUsername: params.ctx.SenderUsername,
|
||||
|
||||
Reference in New Issue
Block a user