mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 20:21:13 +00:00
test: keep cli reliability and fallback coverage off plugin scans
This commit is contained in:
@@ -169,7 +169,6 @@ export function resolveCliBackendConfig(
|
||||
cfg?: OpenClawConfig,
|
||||
): ResolvedCliBackend | null {
|
||||
const normalized = normalizeBackendKey(provider);
|
||||
const fallbackPolicy = resolveFallbackCliBackendPolicy(normalized);
|
||||
const configured = cfg?.agents?.defaults?.cliBackends ?? {};
|
||||
const override = pickBackendConfig(configured, normalized);
|
||||
const registered = resolveRegisteredBackend(normalized);
|
||||
@@ -192,6 +191,7 @@ export function resolveCliBackendConfig(
|
||||
};
|
||||
}
|
||||
|
||||
const fallbackPolicy = resolveFallbackCliBackendPolicy(normalized);
|
||||
if (!override) {
|
||||
if (!fallbackPolicy?.baseConfig) {
|
||||
return null;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { runPreparedCliAgent } from "./cli-runner.js";
|
||||
import {
|
||||
createManagedRun,
|
||||
enqueueSystemEventMock,
|
||||
requestHeartbeatNowMock,
|
||||
EXISTING_CODEX_CONFIG,
|
||||
setupCliRunnerTestModule,
|
||||
supervisorSpawnMock,
|
||||
} from "./cli-runner.test-support.js";
|
||||
import { executePreparedCliRun } from "./cli-runner/execute.js";
|
||||
@@ -140,7 +139,7 @@ describe("runCliAgent reliability", () => {
|
||||
});
|
||||
|
||||
it("rethrows the retry failure when session-expired recovery retry also fails", async () => {
|
||||
const runCliAgent = await setupCliRunnerTestModule();
|
||||
supervisorSpawnMock.mockClear();
|
||||
supervisorSpawnMock.mockResolvedValueOnce(
|
||||
createManagedRun({
|
||||
reason: "exit",
|
||||
@@ -167,19 +166,13 @@ describe("runCliAgent reliability", () => {
|
||||
);
|
||||
|
||||
await expect(
|
||||
runCliAgent({
|
||||
sessionId: "s1",
|
||||
sessionKey: "agent:main:subagent:retry",
|
||||
sessionFile: "/tmp/session.jsonl",
|
||||
workspaceDir: "/tmp",
|
||||
prompt: "hi",
|
||||
provider: "codex-cli",
|
||||
model: "gpt-5.4",
|
||||
config: EXISTING_CODEX_CONFIG,
|
||||
timeoutMs: 1_000,
|
||||
runId: "run-retry-failure",
|
||||
cliSessionId: "thread-123",
|
||||
}),
|
||||
runPreparedCliAgent(
|
||||
buildPreparedContext({
|
||||
sessionKey: "agent:main:subagent:retry",
|
||||
runId: "run-retry-failure",
|
||||
cliSessionId: "thread-123",
|
||||
}),
|
||||
),
|
||||
).rejects.toThrow("rate limit exceeded");
|
||||
|
||||
expect(supervisorSpawnMock).toHaveBeenCalledTimes(2);
|
||||
|
||||
@@ -4,14 +4,20 @@ import type { OpenClawConfig } from "../config/config.js";
|
||||
import { formatErrorMessage } from "../infra/errors.js";
|
||||
import { executePreparedCliRun } from "./cli-runner/execute.js";
|
||||
import { prepareCliRunContext } from "./cli-runner/prepare.js";
|
||||
import type { RunCliAgentParams } from "./cli-runner/types.js";
|
||||
import type { PreparedCliRunContext, RunCliAgentParams } from "./cli-runner/types.js";
|
||||
import { FailoverError, isFailoverError, resolveFailoverStatus } from "./failover-error.js";
|
||||
import { classifyFailoverReason, isFailoverErrorMessage } from "./pi-embedded-helpers.js";
|
||||
import type { EmbeddedPiRunResult } from "./pi-embedded-runner.js";
|
||||
|
||||
export async function runCliAgent(params: RunCliAgentParams): Promise<EmbeddedPiRunResult> {
|
||||
const context = await prepareCliRunContext(params);
|
||||
return runPreparedCliAgent(context);
|
||||
}
|
||||
|
||||
export async function runPreparedCliAgent(
|
||||
context: PreparedCliRunContext,
|
||||
): Promise<EmbeddedPiRunResult> {
|
||||
const { params } = context;
|
||||
const buildCliRunResult = (resultParams: {
|
||||
output: Awaited<ReturnType<typeof executePreparedCliRun>>;
|
||||
effectiveCliSessionId?: string;
|
||||
|
||||
@@ -14,6 +14,11 @@ import { LiveSessionModelSwitchError } from "./live-model-switch-error.js";
|
||||
import { runWithImageModelFallback, runWithModelFallback } from "./model-fallback.js";
|
||||
import { makeModelFallbackCfg } from "./test-helpers/model-fallback-config-fixture.js";
|
||||
|
||||
vi.mock("../plugins/provider-runtime.js", () => ({
|
||||
buildProviderMissingAuthMessageWithPlugin: () => undefined,
|
||||
resolveExternalAuthProfilesWithPlugins: () => [],
|
||||
}));
|
||||
|
||||
const makeCfg = makeModelFallbackCfg;
|
||||
|
||||
function makeFallbacksOnlyCfg(): OpenClawConfig {
|
||||
|
||||
Reference in New Issue
Block a user