Skip to content

Commit d364034

Browse files
committed
test(agents): align execution-state consumers
1 parent 471a130 commit d364034

4 files changed

Lines changed: 9 additions & 18 deletions

‎extensions/codex/src/app-server/dynamic-tool-response-state.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function readDynamicToolExecutionStarted(
1717
return context?.toolExecutionRuntime?.peekStarted(toolCallId, context.runId) ?? fallback;
1818
}
1919

20-
export function readDynamicToolExecutedArguments(
20+
function readDynamicToolExecutedArguments(
2121
context: ToolExecutionContext | undefined,
2222
toolCallId: string,
2323
): Record<string, unknown> | undefined {
@@ -69,7 +69,7 @@ export function withDynamicToolExecutionState<T extends CodexDynamicToolRuntimeR
6969
return withDynamicToolSideEffectEvidence(response, state.sideEffectEvidence === true);
7070
}
7171

72-
export function withDynamicToolSideEffectEvidence<T extends CodexDynamicToolRuntimeResponse>(
72+
function withDynamicToolSideEffectEvidence<T extends CodexDynamicToolRuntimeResponse>(
7373
response: T,
7474
sideEffectEvidence: boolean,
7575
): T {

‎src/agents/agent-tool-definition-adapter.after-tool-call.fires-once.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ async function loadFreshAfterToolCallModulesForTest() {
101101
vi.doMock("./agent-tools.before-tool-call.state.js", () => ({
102102
consumeAdjustedParamsForToolCall: beforeToolCallMocks.consumeAdjustedParamsForToolCall,
103103
consumePreExecutionBlockedToolCall: vi.fn(() => false),
104+
consumeTrackedToolExecutionStarted: vi.fn(() => undefined),
104105
consumeStructuredReplaySafeToolCall: vi.fn(() => false),
105106
}));
106107
vi.doMock("./agent-tools.before-tool-call.js", () => ({

‎src/agents/agent-tools.before-tool-call.integration.e2e.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
wrapToolWithBeforeToolCallHook,
3232
} from "./agent-tools.before-tool-call.js";
3333
import {
34-
consumeToolExecutionStarted,
34+
consumeTrackedToolExecutionStarted,
3535
peekTrackedToolExecutionStarted,
3636
resetAdjustedParamsByToolCallIdForTests,
3737
} from "./agent-tools.before-tool-call.state.js";
@@ -133,7 +133,7 @@ describe("before_tool_call hook integration", () => {
133133
extensionContext,
134134
);
135135
expect(peekTrackedToolExecutionStarted("call-1")).toBe(true);
136-
expect(consumeToolExecutionStarted("call-1")).toBe(true);
136+
expect(consumeTrackedToolExecutionStarted("call-1")).toBe(true);
137137
expect(peekTrackedToolExecutionStarted("call-1")).toBeUndefined();
138138
});
139139

@@ -225,11 +225,11 @@ describe("before_tool_call hook integration", () => {
225225
},
226226
});
227227
expect(execute).not.toHaveBeenCalled();
228-
expect(consumeToolExecutionStarted("call-3")).toBe(false);
228+
expect(consumeTrackedToolExecutionStarted("call-3")).toBe(false);
229229
});
230230

231231
it("does not enter the tool body when a slow hook settles after cancellation", async () => {
232-
let releaseHook = () => undefined;
232+
let releaseHook: () => void = () => {};
233233
const hookGate = new Promise<void>((resolve) => {
234234
releaseHook = resolve;
235235
});
@@ -251,7 +251,7 @@ describe("before_tool_call hook integration", () => {
251251

252252
await expect(result).rejects.toThrow("tool timed out");
253253
expect(execute).not.toHaveBeenCalled();
254-
expect(consumeToolExecutionStarted("call-late-abort")).toBe(false);
254+
expect(consumeTrackedToolExecutionStarted("call-late-abort")).toBe(false);
255255
});
256256

257257
it("does not execute lower-priority hooks after block=true", async () => {

‎src/agents/agent-tools.before-tool-call.state.ts‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
export const adjustedParamsByToolCallId = new Map<string, unknown>();
77
export const preExecutionBlockedToolCallIds = new Set<string>();
88
export const structuredReplaySafeToolCallIds = new Set<string>();
9-
export const startedToolCallIds = new Set<string>();
9+
const startedToolCallIds = new Set<string>();
1010
const trackedToolCallIds = new Set<string>();
1111

1212
export function buildAdjustedParamsKey(params: { runId?: string; toolCallId: string }): string {
@@ -50,11 +50,6 @@ export function recordToolExecutionStarted(toolCallId: string, runId?: string):
5050
startedToolCallIds.add(key);
5151
}
5252

53-
/** Snapshot authoritative evidence without racing another terminal observer. */
54-
export function peekToolExecutionStarted(toolCallId: string, runId?: string): boolean {
55-
return startedToolCallIds.has(buildAdjustedParamsKey({ runId, toolCallId }));
56-
}
57-
5853
/** Return exact wrapped-call state, or undefined for untracked/custom producers. */
5954
export function peekTrackedToolExecutionStarted(
6055
toolCallId: string,
@@ -64,11 +59,6 @@ export function peekTrackedToolExecutionStarted(
6459
return trackedToolCallIds.has(key) ? startedToolCallIds.has(key) : undefined;
6560
}
6661

67-
/** Consume authoritative evidence that the wrapped tool body started. */
68-
export function consumeToolExecutionStarted(toolCallId: string, runId?: string): boolean {
69-
return consumeTrackedToolExecutionStarted(toolCallId, runId) === true;
70-
}
71-
7262
/**
7363
* Consume the wrapped call's exact execution state. Undefined means the call
7464
* came from a producer that does not participate in OpenClaw boundary tracking.

0 commit comments

Comments
 (0)