fix(agents): preserve setup inference auth owner (#122975)

This commit is contained in:
Peter Steinberger
2026-08-12 21:07:28 -07:00
committed by GitHub
parent 88bc628149
commit 48cc78cdd8
2 changed files with 59 additions and 1 deletions
@@ -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();
},
);
});
@@ -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<typeof vi.fn>).mock.calls;
const inferenceReadyIndex = notes.findIndex((call) => call[1] === "Inference ready");
const postInferenceIndex = notes.findIndex(