Skip to content

Commit 48cc78c

Browse files
authored
fix(agents): preserve setup inference auth owner (#122975)
1 parent 88bc628 commit 48cc78c

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import path from "node:path";
2+
import { describe, expect, it } from "vitest";
3+
import type { OpenClawConfig } from "../../config/types.openclaw.js";
4+
import { listAgentIds } from "../agent-scope-config.js";
5+
import { makeAttemptResult } from "./run.overflow-compaction.fixture.js";
6+
import {
7+
loadRunOverflowCompactionHarness,
8+
mockedAcquireAgentRunPreparedModelRuntime,
9+
mockedBuildEmbeddedRunPayloads,
10+
mockedRunEmbeddedAttempt,
11+
overflowBaseRunParams,
12+
} from "./run.overflow-compaction.harness.js";
13+
14+
function projectSetupExecutionConfig(source: OpenClawConfig): OpenClawConfig {
15+
return {
16+
...source,
17+
agents: {
18+
...source.agents,
19+
entries: {
20+
...(source.agents?.entries ?? { main: {} }),
21+
openclaw: {},
22+
},
23+
},
24+
};
25+
}
26+
27+
describe("embedded setup inference inherited auth owner", () => {
28+
it.each([
29+
{ name: "a pre-roster config", source: {} },
30+
{ name: "a sole-agent config", source: { agents: { entries: { main: {} } } } },
31+
] satisfies Array<{ name: string; source: OpenClawConfig }>)(
32+
"prepares the explicit main agent from $name",
33+
async ({ name, source }) => {
34+
const config = projectSetupExecutionConfig(source);
35+
expect(listAgentIds(config)).toEqual(["main", "openclaw"]);
36+
37+
const { runEmbeddedAgent } = await loadRunOverflowCompactionHarness();
38+
mockedBuildEmbeddedRunPayloads.mockReturnValue([{ text: "OK" }]);
39+
mockedRunEmbeddedAttempt.mockResolvedValueOnce(makeAttemptResult({ assistantTexts: ["OK"] }));
40+
41+
await runEmbeddedAgent({
42+
...overflowBaseRunParams,
43+
agentId: "main",
44+
config,
45+
runId: `run-setup-inference-owner-${name}`,
46+
});
47+
48+
const preparedInput = mockedAcquireAgentRunPreparedModelRuntime.mock.calls[0]?.[0];
49+
expect(preparedInput).toMatchObject({ agentId: "main", config });
50+
expect(String(preparedInput?.inheritedAuthDir)).toSatisfy((value: string) =>
51+
value.endsWith(path.join("agents", "main", "agent")),
52+
);
53+
expect(mockedRunEmbeddedAttempt).toHaveBeenCalledOnce();
54+
},
55+
);
56+
});

‎src/commands/onboard-guided.inference.e2e.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ describe("guided onboarding inference composition", () => {
160160
}),
161161
);
162162
expect(mockOpenAi.requestBodies).toHaveLength(1);
163-
expect(JSON.parse(mockOpenAi.requestBodies[0] ?? "{}")).toMatchObject({ model: "gpt-5.6" });
163+
expect(JSON.parse(mockOpenAi.requestBodies[0] ?? "{}")).toMatchObject({
164+
model: "gpt-5.6-sol",
165+
});
164166
const notes = (prompter.note as ReturnType<typeof vi.fn>).mock.calls;
165167
const inferenceReadyIndex = notes.findIndex((call) => call[1] === "Inference ready");
166168
const postInferenceIndex = notes.findIndex(

0 commit comments

Comments
 (0)