mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 14:21:26 +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:
@@ -8,6 +8,7 @@ import {
|
||||
setSessionsSpawnConfigOverride,
|
||||
} from "./openclaw-tools.subagents.sessions-spawn.test-harness.js";
|
||||
import { resetSubagentRegistryForTests } from "./subagent-registry.js";
|
||||
import { SUBAGENT_SPAWN_ACCEPTED_NOTE } from "./subagent-spawn.js";
|
||||
|
||||
const callGatewayMock = getCallGatewayMock();
|
||||
type GatewayCall = { method?: string; params?: unknown };
|
||||
@@ -83,7 +84,7 @@ describe("openclaw-tools: subagents (sessions_spawn model + thinking)", () => {
|
||||
});
|
||||
expect(result.details).toMatchObject({
|
||||
status: "accepted",
|
||||
note: "auto-announces on completion, do not poll/sleep. The response will be sent back as an agent message.",
|
||||
note: SUBAGENT_SPAWN_ACCEPTED_NOTE,
|
||||
modelApplied: true,
|
||||
});
|
||||
|
||||
@@ -254,7 +255,41 @@ describe("openclaw-tools: subagents (sessions_spawn model + thinking)", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("sessions_spawn skips invalid model overrides and continues", async () => {
|
||||
it("sessions_spawn prefers target agent primary model over global default", async () => {
|
||||
resetSubagentRegistryForTests();
|
||||
callGatewayMock.mockReset();
|
||||
setSessionsSpawnConfigOverride({
|
||||
session: { mainKey: "main", scope: "per-sender" },
|
||||
agents: {
|
||||
defaults: { model: { primary: "minimax/MiniMax-M2.1" } },
|
||||
list: [{ id: "research", model: { primary: "opencode/claude" } }],
|
||||
},
|
||||
});
|
||||
const calls: GatewayCall[] = [];
|
||||
mockPatchAndSingleAgentRun({ calls, runId: "run-agent-primary-model" });
|
||||
|
||||
const tool = await getSessionsSpawnTool({
|
||||
agentSessionKey: "agent:research:main",
|
||||
agentChannel: "discord",
|
||||
});
|
||||
|
||||
const result = await tool.execute("call-agent-primary-model", {
|
||||
task: "do thing",
|
||||
});
|
||||
expect(result.details).toMatchObject({
|
||||
status: "accepted",
|
||||
modelApplied: true,
|
||||
});
|
||||
|
||||
const patchCall = calls.find(
|
||||
(call) => call.method === "sessions.patch" && (call.params as { model?: string })?.model,
|
||||
);
|
||||
expect(patchCall?.params).toMatchObject({
|
||||
model: "opencode/claude",
|
||||
});
|
||||
});
|
||||
|
||||
it("sessions_spawn fails when model patch is rejected", async () => {
|
||||
resetSubagentRegistryForTests();
|
||||
callGatewayMock.mockReset();
|
||||
const calls: GatewayCall[] = [];
|
||||
@@ -281,13 +316,10 @@ describe("openclaw-tools: subagents (sessions_spawn model + thinking)", () => {
|
||||
model: "bad-model",
|
||||
});
|
||||
expect(result.details).toMatchObject({
|
||||
status: "accepted",
|
||||
modelApplied: false,
|
||||
status: "error",
|
||||
});
|
||||
expect(String((result.details as { warning?: string }).warning ?? "")).toContain(
|
||||
"invalid model",
|
||||
);
|
||||
expect(calls.some((call) => call.method === "agent")).toBe(true);
|
||||
expect(String((result.details as { error?: string }).error ?? "")).toContain("invalid model");
|
||||
expect(calls.some((call) => call.method === "agent")).toBe(false);
|
||||
});
|
||||
|
||||
it("sessions_spawn supports legacy timeoutSeconds alias", async () => {
|
||||
|
||||
Reference in New Issue
Block a user