Skip to content

Commit f86b69b

Browse files
committed
fix(agents): keep custom CLI harness ids fail-closed
1 parent 80f2770 commit f86b69b

2 files changed

Lines changed: 8 additions & 19 deletions

File tree

‎src/agents/harness/selection.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ describe("selectAgentHarness", () => {
692692
},
693693
);
694694

695-
it("returns PI for an explicit configured cliBackends id instead of throwing", () => {
695+
it("still throws MissingAgentHarnessError for an explicit configured cliBackends id", () => {
696696
const config = {
697697
agents: {
698698
defaults: {
@@ -703,14 +703,14 @@ describe("selectAgentHarness", () => {
703703
},
704704
} as OpenClawConfig;
705705

706-
expect(
706+
expect(() =>
707707
selectAgentHarness({
708708
provider: "anthropic",
709709
modelId: "sonnet-4.6",
710710
agentHarnessRuntimeOverride: "my-custom-cli",
711711
config,
712-
}).id,
713-
).toBe("pi");
712+
}),
713+
).toThrow('Requested agent harness "my-custom-cli" is not registered');
714714
});
715715

716716
it("still throws MissingAgentHarnessError for an explicit non-CLI unknown runtime", () => {

‎src/agents/harness/selection.ts‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
resolveInheritedToolPolicyForSession,
1515
resolveSubagentToolPolicyForSession,
1616
} from "../pi-tools.policy.js";
17-
import { normalizeProviderId } from "../provider-id.js";
1817
import { resolveSandboxRuntimeStatus } from "../sandbox/runtime-status.js";
1918
import { resolveSenderToolPolicy } from "../sender-tool-policy.js";
2019
import {
@@ -61,9 +60,9 @@ type AgentHarnessSelectionDecision = {
6160
| "forced_plugin"
6261
// Implicit Codex preference found no registered Codex harness, so PI handled the run.
6362
| "implicit_plugin_unavailable_pi"
64-
// Explicit CLI runtime alias or configured cliBackends id has no agent harness
65-
// plugin counterpart. PI is returned as the transcript-composition placeholder;
66-
// the actual run is routed through CLI dispatch by callers that consult model
63+
// Explicit provider-owned CLI runtime aliases have no agent harness plugin
64+
// counterpart. PI is returned as the transcript-composition placeholder; the
65+
// actual run is routed through CLI dispatch by callers that consult model
6766
// runtime policy (see `assertModelFallbackCandidateHarnessAvailable`).
6867
| "cli_runtime_passthrough_pi"
6968
// Auto mode chose a registered plugin harness that supports the provider/model.
@@ -77,13 +76,6 @@ function listPluginAgentHarnesses(): AgentHarness[] {
7776
return listRegisteredAgentHarnesses().map((entry) => entry.harness);
7877
}
7978

80-
function hasConfiguredCliBackendId(runtime: string, config: OpenClawConfig | undefined): boolean {
81-
const configured = config?.agents?.defaults?.cliBackends ?? {};
82-
return Object.keys(configured).some(
83-
(key) => normalizeProviderId(key) === normalizeProviderId(runtime),
84-
);
85-
}
86-
8779
export function resolveAvailableAgentHarnessPolicy(params: {
8880
provider?: string;
8981
modelId?: string;
@@ -185,10 +177,7 @@ function selectAgentHarnessDecision(params: {
185177
candidates: listHarnessCandidates(pluginHarnesses),
186178
});
187179
}
188-
if (
189-
isCliRuntimeAliasForProvider({ runtime, provider: params.provider }) ||
190-
hasConfiguredCliBackendId(runtime, params.config)
191-
) {
180+
if (isCliRuntimeAliasForProvider({ runtime, provider: params.provider })) {
192181
return buildSelectionDecision({
193182
harness: piHarness,
194183
policy: {

0 commit comments

Comments
 (0)