test: avoid codex app-server factory race

This commit is contained in:
Peter Steinberger
2026-05-03 16:34:42 +01:00
parent e2c8db2cad
commit 1bfc66da33
2 changed files with 16 additions and 22 deletions

View File

@@ -441,34 +441,27 @@ describe("runCodexAppServerAttempt", () => {
});
it("forces the message dynamic tool for message-tool-only source replies", async () => {
const harness = createStartedThreadHarness();
const params = createParams(
path.join(tempDir, "session.jsonl"),
path.join(tempDir, "workspace"),
);
const workspaceDir = path.join(tempDir, "workspace");
const params = createParams(path.join(tempDir, "session.jsonl"), workspaceDir);
params.disableTools = false;
params.config = { tools: { profile: "coding" } };
params.sourceReplyDeliveryMode = "message_tool_only";
params.messageProvider = "whatsapp";
params.timeoutMs = 60_000;
const run = runCodexAppServerAttempt(params, { turnCompletionIdleTimeoutMs: 5 });
await harness.waitForMethod("thread/start");
await harness.waitForMethod("turn/start");
const startRequest = harness.requests.find((request) => request.method === "thread/start");
const dynamicToolNames = (
(startRequest?.params as { dynamicTools?: Array<{ name: string }> } | undefined)
?.dynamicTools ?? []
).map((tool) => tool.name);
expect(dynamicToolNames).toContain("message");
await new Promise<void>((resolve) => setImmediate(resolve));
await harness.completeTurn({ threadId: "thread-1", turnId: "turn-1" });
await expect(run).resolves.toMatchObject({
timedOut: false,
aborted: false,
const dynamicTools = await __testing.buildDynamicTools({
params,
resolvedWorkspace: workspaceDir,
effectiveWorkspace: workspaceDir,
sandboxSessionKey: params.sessionKey,
sandbox: undefined,
runAbortController: new AbortController(),
sessionAgentId: "main",
pluginConfig: {},
onYieldDetected: () => undefined,
});
const dynamicToolNames = dynamicTools.map((tool) => tool.name);
expect(dynamicToolNames).toContain("message");
});
it("returns a failed dynamic tool response when an app-server tool call exceeds the deadline", async () => {

View File

@@ -1812,6 +1812,7 @@ export const __testing = {
CODEX_TURN_TERMINAL_IDLE_TIMEOUT_MS,
buildCodexNativeHookRelayId,
applyCodexDynamicToolProfile,
buildDynamicTools,
filterToolsForVisionInputs,
handleDynamicToolCallWithTimeout,
...createCodexAppServerClientFactoryTestHooks((factory) => {