mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-26 09:21:55 +00:00
fix(plugins): forward plugin subagent overrides
This commit is contained in:
@@ -51,6 +51,11 @@ function getLastDispatchedContext(): GatewayRequestContext | undefined {
|
||||
return call?.context;
|
||||
}
|
||||
|
||||
function getLastDispatchedParams(): Record<string, unknown> | undefined {
|
||||
const call = handleGatewayRequest.mock.calls.at(-1)?.[0];
|
||||
return call?.req?.params as Record<string, unknown> | undefined;
|
||||
}
|
||||
|
||||
async function importServerPluginsModule(): Promise<ServerPluginsModule> {
|
||||
return import("./server-plugins.js");
|
||||
}
|
||||
@@ -178,6 +183,28 @@ describe("loadGatewayPlugins", () => {
|
||||
expect(typeof subagent?.getSession).toBe("function");
|
||||
});
|
||||
|
||||
test("forwards provider and model overrides for agent runs", async () => {
|
||||
const serverPlugins = await importServerPluginsModule();
|
||||
const runtime = await createSubagentRuntime(serverPlugins);
|
||||
serverPlugins.setFallbackGatewayContext(createTestContext("forward-overrides"));
|
||||
|
||||
await runtime.run({
|
||||
sessionKey: "s-override",
|
||||
message: "use the override",
|
||||
provider: "anthropic",
|
||||
model: "claude-haiku-4-6",
|
||||
deliver: false,
|
||||
});
|
||||
|
||||
expect(getLastDispatchedParams()).toMatchObject({
|
||||
sessionKey: "s-override",
|
||||
message: "use the override",
|
||||
provider: "anthropic",
|
||||
model: "claude-haiku-4-6",
|
||||
deliver: false,
|
||||
});
|
||||
});
|
||||
|
||||
test("can prefer setup-runtime channel plugins during startup loads", async () => {
|
||||
const { loadGatewayPlugins } = await importServerPluginsModule();
|
||||
loadOpenClawPlugins.mockReturnValue(createRegistry([]));
|
||||
@@ -236,7 +263,6 @@ describe("loadGatewayPlugins", () => {
|
||||
expect(log.error).not.toHaveBeenCalled();
|
||||
expect(log.info).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("shares fallback context across module reloads for existing runtimes", async () => {
|
||||
const first = await importServerPluginsModule();
|
||||
const runtime = await createSubagentRuntime(first);
|
||||
|
||||
@@ -120,6 +120,8 @@ function createGatewaySubagentRuntime(): PluginRuntime["subagent"] {
|
||||
sessionKey: params.sessionKey,
|
||||
message: params.message,
|
||||
deliver: params.deliver ?? false,
|
||||
...(params.provider && { provider: params.provider }),
|
||||
...(params.model && { model: params.model }),
|
||||
...(params.extraSystemPrompt && { extraSystemPrompt: params.extraSystemPrompt }),
|
||||
...(params.lane && { lane: params.lane }),
|
||||
...(params.idempotencyKey && { idempotencyKey: params.idempotencyKey }),
|
||||
|
||||
Reference in New Issue
Block a user