Skip to content

Commit ad0adad

Browse files
committed
fix(codex): keep progress card directly visible
1 parent b4a720f commit ad0adad

4 files changed

Lines changed: 57 additions & 26 deletions

File tree

‎extensions/codex/src/app-server/dynamic-tools.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import path from "node:path";
55
import type { AgentToolResult } from "openclaw/plugin-sdk/agent-core";
66
import type { AnyAgentTool } from "openclaw/plugin-sdk/agent-harness";
77
import {
8+
type EmbeddedRunAttemptParamsV2 as EmbeddedRunAttemptParams,
89
HEARTBEAT_RESPONSE_TOOL_NAME,
910
embeddedAgentLog,
1011
getPluginToolMeta,
@@ -51,6 +52,7 @@ import {
5152
type JsonValue,
5253
} from "./protocol.js";
5354
import type { CodexRemoteWorkspaceFileReader } from "./remote-workspace-media.js";
55+
import { resolveCodexDynamicToolDirectNames } from "./run-attempt-tools.js";
5456
import { codexDynamicToolsFingerprint } from "./thread-fingerprints.js";
5557

5658
const CODEX_OPENCLAW_DYNAMIC_TOOL_NAMESPACE = "openclaw";
@@ -763,6 +765,25 @@ describe("createCodexDynamicToolBridge", () => {
763765
expectNoNamespace(specs.find((tool) => tool.name === "message"));
764766
});
765767

768+
it("keeps progress_card direct when searchable loading defers broad tools", () => {
769+
const bridge = createCodexDynamicToolBridge({
770+
tools: [createTool({ name: "progress_card" }), createTool({ name: "web_search" })],
771+
signal: new AbortController().signal,
772+
loading: "searchable",
773+
directToolNames: resolveCodexDynamicToolDirectNames({} as EmbeddedRunAttemptParams),
774+
});
775+
776+
const specs = flattenSpecsWithNamespace(bridge.specs);
777+
const progressCard = specs.find((tool) => tool.name === "progress_card");
778+
const webSearch = specs.find((tool) => tool.name === "web_search");
779+
expectNoNamespace(progressCard);
780+
expectDynamicSpec(webSearch, {
781+
name: "web_search",
782+
namespace: CODEX_OPENCLAW_DYNAMIC_TOOL_NAMESPACE,
783+
deferLoading: true,
784+
});
785+
});
786+
766787
it("isolates direct-only tools in Codex's model-only namespace", () => {
767788
const bridge = createCodexDynamicToolBridge({
768789
tools: [
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { EmbeddedRunAttemptParamsV2 as EmbeddedRunAttemptParams } from "openclaw/plugin-sdk/agent-harness-runtime";
2+
import { describe, expect, it } from "vitest";
3+
import { resolveCodexDynamicToolDirectNames } from "./run-attempt-tools.js";
4+
5+
function createAttemptParams(
6+
overrides: Partial<EmbeddedRunAttemptParams> = {},
7+
): EmbeddedRunAttemptParams {
8+
return overrides as EmbeddedRunAttemptParams;
9+
}
10+
11+
describe("resolveCodexDynamicToolDirectNames", () => {
12+
it.each([
13+
{ label: "normal", restricted: false },
14+
{ label: "restricted", restricted: true },
15+
])("keeps progress_card direct for $label runs", ({ restricted }) => {
16+
const params = createAttemptParams({ pluginHarnessToolPolicyRestricted: restricted });
17+
18+
expect(resolveCodexDynamicToolDirectNames(params)).toEqual(["progress_card"]);
19+
});
20+
21+
it("preserves ring-zero and message tools alongside progress_card", () => {
22+
const ringZeroParams = createAttemptParams({ toolsAllow: ["openclaw"] });
23+
const messageParams = createAttemptParams({ sourceReplyDeliveryMode: "message_tool_only" });
24+
25+
expect(resolveCodexDynamicToolDirectNames(ringZeroParams, true)).toEqual([
26+
"openclaw",
27+
"progress_card",
28+
]);
29+
expect(resolveCodexDynamicToolDirectNames(messageParams)).toEqual(["message", "progress_card"]);
30+
});
31+
});

‎extensions/codex/src/app-server/run-attempt-tools.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,8 @@ export function resolveCodexDynamicToolDirectNames(
8888
if (params.sourceReplyDeliveryMode === "message_tool_only") {
8989
names.push("message");
9090
}
91-
// Restricted plugin runs replace Codex's native tool surface with an exact
92-
// OpenClaw policy-filtered catalog. Keep the replacement planner visible in
93-
// the initial context so Codex can maintain the same user-facing plan stream.
94-
if (params.pluginHarnessToolPolicyRestricted === true) {
95-
names.push("progress_card");
96-
}
91+
// OpenClaw disables Codex's native update_plan on every thread. Keep its
92+
// replacement in the initial context or the run has no visible progress tool.
93+
names.push("progress_card");
9794
return names;
9895
}

‎extensions/codex/src/app-server/run-attempt.test.ts‎

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import {
7474
type v2,
7575
} from "./protocol.js";
7676
import { itemNotification, rawItemCompleted, turnCompleted } from "./protocol.test-helpers.js";
77+
import { resolveCodexDynamicToolDirectNames } from "./run-attempt-tools.js";
7778

7879
type CodexAppServerToolTelemetry = Parameters<CodexAppServerEventProjector["buildResult"]>[0];
7980
import {
@@ -153,26 +154,7 @@ const testing = {
153154
buildDeveloperInstructions,
154155
buildDynamicTools,
155156
filterCodexDynamicTools,
156-
resolveCodexDynamicToolDirectNames(
157-
params: EmbeddedRunAttemptParams,
158-
hostSystemAgentActive = false,
159-
): string[] {
160-
const names: string[] = [];
161-
if (
162-
hostSystemAgentActive &&
163-
params.toolsAllow?.length === 1 &&
164-
params.toolsAllow[0] === "openclaw"
165-
) {
166-
names.push("openclaw");
167-
}
168-
if (params.sourceReplyDeliveryMode === "message_tool_only") {
169-
names.push("message");
170-
}
171-
if (params.pluginHarnessToolPolicyRestricted === true) {
172-
names.push("progress_card");
173-
}
174-
return names;
175-
},
157+
resolveCodexDynamicToolDirectNames,
176158
setOpenClawCodingToolsFactoryForTests(
177159
factory: NonNullable<typeof dynamicToolBuildState.openClawCodingToolsFactory>,
178160
): void {

0 commit comments

Comments
 (0)