diff --git a/src/agents/embedded-agent-runner/run.inherited-auth-owner.test.ts b/src/agents/embedded-agent-runner/run.inherited-auth-owner.test.ts new file mode 100644 index 000000000000..a250b307bd4b --- /dev/null +++ b/src/agents/embedded-agent-runner/run.inherited-auth-owner.test.ts @@ -0,0 +1,56 @@ +import path from "node:path"; +import { describe, expect, it } from "vitest"; +import type { OpenClawConfig } from "../../config/types.openclaw.js"; +import { listAgentIds } from "../agent-scope-config.js"; +import { makeAttemptResult } from "./run.overflow-compaction.fixture.js"; +import { + loadRunOverflowCompactionHarness, + mockedAcquireAgentRunPreparedModelRuntime, + mockedBuildEmbeddedRunPayloads, + mockedRunEmbeddedAttempt, + overflowBaseRunParams, +} from "./run.overflow-compaction.harness.js"; + +function projectSetupExecutionConfig(source: OpenClawConfig): OpenClawConfig { + return { + ...source, + agents: { + ...source.agents, + entries: { + ...(source.agents?.entries ?? { main: {} }), + openclaw: {}, + }, + }, + }; +} + +describe("embedded setup inference inherited auth owner", () => { + it.each([ + { name: "a pre-roster config", source: {} }, + { name: "a sole-agent config", source: { agents: { entries: { main: {} } } } }, + ] satisfies Array<{ name: string; source: OpenClawConfig }>)( + "prepares the explicit main agent from $name", + async ({ name, source }) => { + const config = projectSetupExecutionConfig(source); + expect(listAgentIds(config)).toEqual(["main", "openclaw"]); + + const { runEmbeddedAgent } = await loadRunOverflowCompactionHarness(); + mockedBuildEmbeddedRunPayloads.mockReturnValue([{ text: "OK" }]); + mockedRunEmbeddedAttempt.mockResolvedValueOnce(makeAttemptResult({ assistantTexts: ["OK"] })); + + await runEmbeddedAgent({ + ...overflowBaseRunParams, + agentId: "main", + config, + runId: `run-setup-inference-owner-${name}`, + }); + + const preparedInput = mockedAcquireAgentRunPreparedModelRuntime.mock.calls[0]?.[0]; + expect(preparedInput).toMatchObject({ agentId: "main", config }); + expect(String(preparedInput?.inheritedAuthDir)).toSatisfy((value: string) => + value.endsWith(path.join("agents", "main", "agent")), + ); + expect(mockedRunEmbeddedAttempt).toHaveBeenCalledOnce(); + }, + ); +}); diff --git a/src/commands/onboard-guided.inference.e2e.test.ts b/src/commands/onboard-guided.inference.e2e.test.ts index d4ab1cba0667..528d1b07d1de 100644 --- a/src/commands/onboard-guided.inference.e2e.test.ts +++ b/src/commands/onboard-guided.inference.e2e.test.ts @@ -160,7 +160,9 @@ describe("guided onboarding inference composition", () => { }), ); expect(mockOpenAi.requestBodies).toHaveLength(1); - expect(JSON.parse(mockOpenAi.requestBodies[0] ?? "{}")).toMatchObject({ model: "gpt-5.6" }); + expect(JSON.parse(mockOpenAi.requestBodies[0] ?? "{}")).toMatchObject({ + model: "gpt-5.6-sol", + }); const notes = (prompter.note as ReturnType).mock.calls; const inferenceReadyIndex = notes.findIndex((call) => call[1] === "Inference ready"); const postInferenceIndex = notes.findIndex(