mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
fix: guard resumeSessionId against non-ACP runtime
Add early-return error when resumeSessionId is passed without runtime="acp" (mirrors existing streamTo guard). Without this, the parameter is silently ignored and the agent gets a fresh session instead of resuming. Also update schema description to note the runtime=acp requirement. Addresses Greptile review feedback.
This commit is contained in:
@@ -185,6 +185,21 @@ describe("sessions_spawn tool", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects resumeSessionId without runtime=acp", async () => {
|
||||
const tool = createSessionsSpawnTool({
|
||||
agentSessionKey: "agent:main:main",
|
||||
});
|
||||
|
||||
const result = await tool.execute("call-guard", {
|
||||
task: "resume prior work",
|
||||
resumeSessionId: "7f4a78e0-f6be-43fe-855c-c1c4fd229bc4",
|
||||
});
|
||||
|
||||
expect(JSON.stringify(result)).toContain("resumeSessionId is only supported for runtime=acp");
|
||||
expect(hoisted.spawnSubagentDirectMock).not.toHaveBeenCalled();
|
||||
expect(hoisted.spawnAcpDirectMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("rejects attachments for ACP runtime", async () => {
|
||||
const tool = createSessionsSpawnTool({
|
||||
agentSessionKey: "agent:main:main",
|
||||
|
||||
@@ -28,7 +28,7 @@ const SessionsSpawnToolSchema = Type.Object({
|
||||
resumeSessionId: Type.Optional(
|
||||
Type.String({
|
||||
description:
|
||||
"Resume an existing agent session by its ID (e.g. a Codex session UUID from ~/.codex/sessions/). The agent replays conversation history via session/load instead of starting fresh.",
|
||||
'Resume an existing agent session by its ID (e.g. a Codex session UUID from ~/.codex/sessions/). Requires runtime="acp". The agent replays conversation history via session/load instead of starting fresh.',
|
||||
}),
|
||||
),
|
||||
model: Type.Optional(Type.String()),
|
||||
@@ -134,6 +134,13 @@ export function createSessionsSpawnTool(
|
||||
});
|
||||
}
|
||||
|
||||
if (resumeSessionId && runtime !== "acp") {
|
||||
return jsonResult({
|
||||
status: "error",
|
||||
error: `resumeSessionId is only supported for runtime=acp; got runtime=${runtime}`,
|
||||
});
|
||||
}
|
||||
|
||||
if (runtime === "acp") {
|
||||
if (Array.isArray(attachments) && attachments.length > 0) {
|
||||
return jsonResult({
|
||||
|
||||
Reference in New Issue
Block a user