Skip to content

Commit a0498f7

Browse files
jalehmansteipete
andauthored
fix: restore native OpenAI web search in packaged runs (#124215)
* oc-e13.2: preserve web search failure evidence * oc-e13.2: include provider owners in runtime plans * oc-e13.2: prepare provider owners before harnesses * oc-e13.2: retain provider selections in runtime owners * oc-e13.2: keep harness selection helper internal * test(agents): cover prepared runtime registry loads Co-authored-by: Josh Lehman <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
1 parent bb68ad0 commit a0498f7

6 files changed

Lines changed: 105 additions & 29 deletions

File tree

‎scripts/e2e/lib/openai-web-search-minimal/scenario.sh‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ trap cleanup EXIT
4141

4242
dump_debug_logs() {
4343
local status="$1"
44+
local failed_command="$2"
4445
echo "OpenAI web_search minimal Docker E2E failed with exit code $status" >&2
4546
for file in \
4647
"$GATEWAY_LOG" \
@@ -51,11 +52,12 @@ dump_debug_logs() {
5152
"$OPENCLAW_STATE_DIR/openclaw.json"; do
5253
if [ -f "$file" ]; then
5354
echo "--- $file ---" >&2
54-
openclaw_e2e_print_log "$file" >&2
55+
OPENCLAW_E2E_LOG_TAIL_BYTES=8192 openclaw_e2e_print_log "$file" >&2
5556
fi
5657
done
58+
echo "OpenAI web_search minimal failed command: $failed_command" >&2
5759
}
58-
trap 'status=$?; dump_debug_logs "$status"; exit "$status"' ERR
60+
trap 'status=$?; dump_debug_logs "$status" "$BASH_COMMAND"; exit "$status"' ERR
5961

6062
entry="$(openclaw_e2e_resolve_entrypoint)"
6163
mkdir -p "$OPENCLAW_STATE_DIR" "$TLS_DIR"

‎src/agents/harness/runtime-plugin-load-plan.ts‎

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,41 @@ function resolveSelectedMemoryPluginIds(params: {
7777
: [];
7878
}
7979

80+
// Every selected model provider must join the immutable run generation before
81+
// request-time hooks resolve; late provider loading is intentionally forbidden.
82+
function resolveSelectedProviderOwnerPluginIds(params: {
83+
provider: string;
84+
config?: OpenClawConfig;
85+
workspaceDir: string;
86+
}): string[] {
87+
const providerOwnerPluginIds = dedupePluginIds(
88+
resolveOwningPluginIdsForProviderRef(params) ?? [],
89+
);
90+
if (providerOwnerPluginIds.length === 0) {
91+
return [];
92+
}
93+
const safeProviderOwnerPluginIds = dedupePluginIds([
94+
...resolveBundledProviderCompatPluginIds({
95+
config: params.config,
96+
workspaceDir: params.workspaceDir,
97+
onlyPluginIds: providerOwnerPluginIds,
98+
}),
99+
...resolveActivatableProviderOwnerPluginIds({
100+
pluginIds: providerOwnerPluginIds,
101+
config: params.config,
102+
workspaceDir: params.workspaceDir,
103+
}),
104+
]);
105+
return providerOwnerPluginIds.filter((pluginId) => safeProviderOwnerPluginIds.includes(pluginId));
106+
}
107+
80108
/** Resolve manifest owners required by one selected non-core harness runtime. */
81109
export function resolveAgentHarnessOwnerPluginIds(params: {
82110
runtime: string;
83111
provider: string;
84112
config?: OpenClawConfig;
85113
workspaceDir: string;
114+
providerOwnerPluginIds?: readonly string[];
86115
}): string[] {
87116
const harnessPluginIds = resolveManifestActivationPlan({
88117
trigger: { kind: "agentHarness", runtime: params.runtime },
@@ -98,29 +127,14 @@ export function resolveAgentHarnessOwnerPluginIds(params: {
98127
) {
99128
return harnessPluginIds;
100129
}
101-
const providerOwnerPluginIds = dedupePluginIds(
102-
resolveOwningPluginIdsForProviderRef(params) ?? [],
103-
);
130+
const providerOwnerPluginIds =
131+
params.providerOwnerPluginIds ?? resolveSelectedProviderOwnerPluginIds(params);
104132
if (providerOwnerPluginIds.length === 0) {
105133
return harnessPluginIds;
106134
}
107-
const safeProviderOwnerPluginIds = dedupePluginIds([
108-
...resolveBundledProviderCompatPluginIds({
109-
config: params.config,
110-
workspaceDir: params.workspaceDir,
111-
onlyPluginIds: providerOwnerPluginIds,
112-
}),
113-
...resolveActivatableProviderOwnerPluginIds({
114-
pluginIds: providerOwnerPluginIds,
115-
config: params.config,
116-
workspaceDir: params.workspaceDir,
117-
}),
118-
]);
119135
return dedupePluginIds([
120136
...harnessPluginIds,
121-
...providerOwnerPluginIds.filter(
122-
(pluginId) => pluginId !== "codex" && safeProviderOwnerPluginIds.includes(pluginId),
123-
),
137+
...providerOwnerPluginIds.filter((pluginId) => pluginId !== "codex"),
124138
]);
125139
}
126140

@@ -157,8 +171,8 @@ export function resolveSelectedAgentHarnessRuntime(
157171
}).runtime;
158172
}
159173

160-
/** Returns whether a selection needs a plugin-owned harness in its prepared generation. */
161-
export function requiresAgentHarnessPluginSelection(
174+
// Returns whether a selection needs a plugin-owned harness in its prepared generation.
175+
function requiresAgentHarnessPluginSelection(
162176
selection: AgentHarnessPluginSelection,
163177
config?: OpenClawConfig,
164178
): boolean {
@@ -195,6 +209,13 @@ export function resolveAgentRuntimePluginLoadPlan(params: {
195209
const forceActivatedPluginIds = [...memoryPluginIds, ...contextEnginePluginIds];
196210
for (const selection of params.selections) {
197211
const runtime = resolveSelectedAgentHarnessRuntime(selection, config);
212+
const providerOwnerPluginIds = resolveSelectedProviderOwnerPluginIds({
213+
provider: selection.provider,
214+
config,
215+
workspaceDir: params.workspaceDir,
216+
});
217+
pluginIds.push(...providerOwnerPluginIds);
218+
forceActivatedPluginIds.push(...providerOwnerPluginIds);
198219
if (!requiresAgentHarnessPluginSelection(selection, config)) {
199220
continue;
200221
}
@@ -203,6 +224,7 @@ export function resolveAgentRuntimePluginLoadPlan(params: {
203224
provider: selection.provider,
204225
config,
205226
workspaceDir: params.workspaceDir,
227+
providerOwnerPluginIds,
206228
});
207229
pluginIds.push(...harnessPluginIds);
208230
const allowedHarnessPluginIds =

‎src/agents/harness/runtime-plugin.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,33 @@ describe("harness runtime plugins", () => {
8787
expect(plan.config?.plugins?.entries?.codex).toEqual({ enabled: true });
8888
});
8989

90+
it("includes the selected provider owner for the default runtime", () => {
91+
mocks.resolveOwningPluginIdsForProvider.mockReturnValueOnce(["openai"]);
92+
mocks.resolveActivatableProviderOwnerPluginIds.mockReturnValueOnce(["openai"]);
93+
const plan = resolveAgentRuntimePluginLoadPlan({
94+
config: { plugins: { allow: ["openai"] } },
95+
workspaceDir: "/tmp/workspace",
96+
selections: [{ provider: "openai", modelId: "gpt-5.5", runtime: "openclaw" }],
97+
});
98+
99+
expect(plan.pluginIds).toEqual(["openai"]);
100+
expect(plan.config?.plugins?.entries?.openai).toEqual({ enabled: true });
101+
});
102+
103+
it("includes the selected provider owner when policy selects an omitted harness", () => {
104+
mocks.resolveOwningPluginIdsForProvider.mockReturnValueOnce(["openai"]);
105+
mocks.resolveActivatableProviderOwnerPluginIds.mockReturnValueOnce(["openai"]);
106+
mocks.resolveManifestActivationPlan.mockReturnValueOnce({ entries: [] });
107+
const plan = resolveAgentRuntimePluginLoadPlan({
108+
config: { plugins: { allow: ["openai"] } },
109+
workspaceDir: "/tmp/workspace",
110+
selections: [{ provider: "openai", modelId: "gpt-5" }],
111+
});
112+
113+
expect(plan.pluginIds).toEqual(["openai"]);
114+
expect(plan.config?.plugins?.entries?.openai).toEqual({ enabled: true });
115+
});
116+
90117
it("includes and enables the context-engine owner in the prepared load plan", () => {
91118
const plan = resolveAgentRuntimePluginLoadPlan({
92119
config: { plugins: { slots: { contextEngine: "custom-context-engine" } } },

‎src/agents/prepared-model-runtime.owner-selection.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,29 @@ describe("prepared model runtime owner selection", () => {
153153
).rejects.toThrow("prepared model runtime owner was not published");
154154
});
155155

156+
it("publishes provider selections kept on the core runtime by request parameters", async () => {
157+
mocks.configuredAgentIds = ["default"];
158+
const config = {
159+
agents: {
160+
defaults: {
161+
model: "openai/gpt-5",
162+
models: {
163+
"openai/gpt-5": { params: { transport: "sse", openaiWsWarmup: false } },
164+
},
165+
},
166+
},
167+
};
168+
169+
await refreshPreparedModelRuntimeSnapshots(config, {
170+
catalogMode: "static",
171+
gatewayLifecycle: true,
172+
});
173+
174+
expect(
175+
mocks.loadAgentRuntimePluginRegistryHandle.mock.calls.map((call) => call[0].selections),
176+
).toContainEqual([{ provider: "openai", modelId: "gpt-5", runtime: "openclaw" }]);
177+
});
178+
156179
it("reuses the configured owner for its prepared plugin harness selections", async () => {
157180
mocks.configuredAgentIds = ["default"];
158181
const config = { agents: { defaults: { model: "openai/gpt-5.5" } } };

‎src/agents/prepared-model-runtime.owner.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import {
1111
resolveAgentWorkspaceDir,
1212
} from "./agent-scope.js";
1313
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "./defaults.js";
14-
import {
15-
requiresAgentHarnessPluginSelection,
16-
resolveSelectedAgentHarnessRuntime,
17-
} from "./harness/runtime-plugin-load-plan.js";
14+
import { resolveSelectedAgentHarnessRuntime } from "./harness/runtime-plugin-load-plan.js";
1815
import { resolveLegacyInheritedAuthDir } from "./legacy-inherited-auth-dir.js";
1916
import { resolveModelCandidateChain } from "./model-fallback-candidates.js";
2017
import { resolveDefaultModelForAgent } from "./model-selection-config.js";
@@ -222,7 +219,6 @@ export function normalizePreparedModelRuntimeInput(
222219
const runtimePluginSelections = input.runtimePluginSelections
223220
? Object.freeze(
224221
[...input.runtimePluginSelections]
225-
.filter((selection) => requiresAgentHarnessPluginSelection(selection, input.config))
226222
.map((selection) => {
227223
const runtime = resolveSelectedAgentHarnessRuntime(selection, input.config);
228224
const { agentId: _agentId, ...normalized } = selection;

‎src/agents/prepared-model-runtime.startup-static.test.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,13 @@ describe("prepared model runtime Gateway catalog mode", () => {
361361
});
362362

363363
expect(mocks.ensureOpenClawModelsJson).not.toHaveBeenCalled();
364-
expect(mocks.loadAgentRuntimePluginRegistryHandle).toHaveBeenCalledOnce();
364+
expect(mocks.loadAgentRuntimePluginRegistryHandle).toHaveBeenCalledTimes(2);
365+
expect(mocks.loadAgentRuntimePluginRegistryHandle.mock.calls[0]?.[0]).not.toHaveProperty(
366+
"selections",
367+
);
368+
expect(mocks.loadAgentRuntimePluginRegistryHandle.mock.calls[1]?.[0]).toMatchObject({
369+
selections: [{ provider: "openai", modelId: "gpt-5.5", runtime: "openclaw" }],
370+
});
365371
expect(mocks.prepareStaticCatalog).toHaveBeenCalledWith(
366372
expect.objectContaining({
367373
providerDiscoveryProviderIds: ["openai"],
@@ -414,7 +420,7 @@ describe("prepared model runtime Gateway catalog mode", () => {
414420
await snapshot?.loadFullModelCatalog?.();
415421
expect(mocks.ensureOpenClawModelsJson).not.toHaveBeenCalled();
416422
expect(mocks.runPreparedModelCatalogWorker).toHaveBeenCalledOnce();
417-
expect(mocks.loadAgentRuntimePluginRegistryHandle).toHaveBeenCalledOnce();
423+
expect(mocks.loadAgentRuntimePluginRegistryHandle).toHaveBeenCalledTimes(2);
418424

419425
await expect(snapshot?.loadFullModelCatalog?.()).resolves.toEqual({
420426
entries: [],

0 commit comments

Comments
 (0)