mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 00:31:24 +00:00
fix(cli): display correct model for sub-agents in sessions list (#18660)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: ba54c5a351
Co-authored-by: robbyczgw-cla <239660374+robbyczgw-cla@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -238,4 +238,37 @@ describe("sessions_spawn depth + child limits", () => {
|
||||
runId: "run-depth",
|
||||
});
|
||||
});
|
||||
|
||||
it("fails spawn when sessions.patch rejects the model", async () => {
|
||||
setSubagentLimits({ maxSpawnDepth: 2 });
|
||||
callGatewayMock.mockImplementation(async (opts: unknown) => {
|
||||
const req = opts as { method?: string; params?: { model?: string } };
|
||||
if (req.method === "sessions.patch" && req.params?.model === "bad-model") {
|
||||
throw new Error("invalid model: bad-model");
|
||||
}
|
||||
if (req.method === "agent") {
|
||||
return { runId: "run-depth" };
|
||||
}
|
||||
if (req.method === "agent.wait") {
|
||||
return { status: "running" };
|
||||
}
|
||||
return {};
|
||||
});
|
||||
|
||||
const tool = createSessionsSpawnTool({ agentSessionKey: "main" });
|
||||
const result = await tool.execute("call-model-reject", {
|
||||
task: "hello",
|
||||
model: "bad-model",
|
||||
});
|
||||
|
||||
expect(result.details).toMatchObject({
|
||||
status: "error",
|
||||
});
|
||||
expect(String((result.details as { error?: string }).error ?? "")).toContain("invalid model");
|
||||
expect(
|
||||
callGatewayMock.mock.calls.some(
|
||||
(call) => (call[0] as { method?: string }).method === "agent",
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user