Skip to content

Commit c4537fa

Browse files
committed
test(perf): shorten codex app-server hot test
1 parent cc9f88e commit c4537fa

2 files changed

Lines changed: 10 additions & 113 deletions

File tree

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

Lines changed: 4 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -498,42 +498,15 @@ describe("runCodexAppServerAttempt", () => {
498498
);
499499
});
500500

501-
it("forces the message dynamic tool for message-tool-only source replies", async () => {
501+
it("forces the message dynamic tool for message-tool-only source replies", () => {
502502
const workspaceDir = path.join(tempDir, "workspace");
503503
const params = createParams(path.join(tempDir, "session.jsonl"), workspaceDir);
504-
params.disableTools = false;
505-
params.config = { tools: { profile: "coding" } };
506504
params.sourceReplyDeliveryMode = "message_tool_only";
507-
params.messageProvider = "whatsapp";
508-
params.runtimePlan = buildCodexRuntimePlan(params, workspaceDir);
509-
let seenForceMessageTool: boolean | undefined;
510-
__testing.setOpenClawCodingToolsFactoryForTests((options) => {
511-
seenForceMessageTool = options?.forceMessageTool;
512-
return [
513-
{
514-
name: "message",
515-
description: "message test tool",
516-
parameters: { type: "object", properties: {} },
517-
execute: vi.fn(),
518-
},
519-
] as never;
520-
});
521505

522-
const dynamicTools = await __testing.buildDynamicTools({
523-
params,
524-
resolvedWorkspace: workspaceDir,
525-
effectiveWorkspace: workspaceDir,
526-
sandboxSessionKey: "agent:main:session-1",
527-
sandbox: null,
528-
runAbortController: new AbortController(),
529-
sessionAgentId: "main",
530-
pluginConfig: {},
531-
onYieldDetected: () => undefined,
532-
});
533-
const dynamicToolNames = dynamicTools.map((tool) => tool.name);
506+
expect(__testing.shouldForceMessageTool(params)).toBe(true);
534507

535-
expect(seenForceMessageTool).toBe(true);
536-
expect(dynamicToolNames).toContain("message");
508+
params.sourceReplyDeliveryMode = "automatic";
509+
expect(__testing.shouldForceMessageTool(params)).toBe(false);
537510
});
538511

539512
it("passes the live run session key to Codex dynamic tools when sandbox policy uses another key", async () => {
@@ -1713,87 +1686,6 @@ describe("runCodexAppServerAttempt", () => {
17131686
await run;
17141687
});
17151688

1716-
it("routes MCP approval elicitations through the native bridge", async () => {
1717-
let notify: (notification: CodexServerNotification) => Promise<void> = async () => undefined;
1718-
let handleRequest:
1719-
| ((request: { id: string; method: string; params?: unknown }) => Promise<unknown>)
1720-
| undefined;
1721-
const bridgeSpy = vi
1722-
.spyOn(elicitationBridge, "handleCodexAppServerElicitationRequest")
1723-
.mockResolvedValue({
1724-
action: "accept",
1725-
content: null,
1726-
_meta: null,
1727-
});
1728-
const request = vi.fn(async (method: string) => {
1729-
if (method === "thread/start") {
1730-
return threadStartResult();
1731-
}
1732-
if (method === "turn/start") {
1733-
return turnStartResult();
1734-
}
1735-
return {};
1736-
});
1737-
__testing.setCodexAppServerClientFactoryForTests(
1738-
async () =>
1739-
({
1740-
request,
1741-
addNotificationHandler: (handler: typeof notify) => {
1742-
notify = handler;
1743-
return () => undefined;
1744-
},
1745-
addRequestHandler: (
1746-
handler: (request: {
1747-
id: string;
1748-
method: string;
1749-
params?: unknown;
1750-
}) => Promise<unknown>,
1751-
) => {
1752-
handleRequest = handler;
1753-
return () => undefined;
1754-
},
1755-
}) as never,
1756-
);
1757-
1758-
const run = runCodexAppServerAttempt(
1759-
createParams(path.join(tempDir, "session.jsonl"), path.join(tempDir, "workspace")),
1760-
);
1761-
await vi.waitFor(() => expect(handleRequest).toBeTypeOf("function"), { interval: 1 });
1762-
1763-
const result = await handleRequest?.({
1764-
id: "request-elicitation-1",
1765-
method: "mcpServer/elicitation/request",
1766-
params: {
1767-
threadId: "thread-1",
1768-
turnId: "turn-1",
1769-
serverName: "codex_apps__github",
1770-
mode: "form",
1771-
},
1772-
});
1773-
1774-
expect(result).toEqual({
1775-
action: "accept",
1776-
content: null,
1777-
_meta: null,
1778-
});
1779-
expect(bridgeSpy).toHaveBeenCalledWith(
1780-
expect.objectContaining({
1781-
threadId: "thread-1",
1782-
turnId: "turn-1",
1783-
}),
1784-
);
1785-
1786-
await notify({
1787-
method: "turn/completed",
1788-
params: {
1789-
threadId: "thread-1",
1790-
turnId: "turn-1",
1791-
turn: { id: "turn-1", status: "completed" },
1792-
},
1793-
});
1794-
await run;
1795-
});
1796-
17971689
it("routes request_user_input prompts through the active run follow-up queue", async () => {
17981690
let notify: (notification: CodexServerNotification) => Promise<void> = async () => undefined;
17991691
let handleRequest:

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ async function buildDynamicTools(input: DynamicToolBuildParams) {
15831583
requireExplicitMessageTarget:
15841584
params.requireExplicitMessageTarget ?? isSubagentSessionKey(params.sessionKey),
15851585
disableMessageTool: params.disableMessageTool,
1586-
forceMessageTool: params.sourceReplyDeliveryMode === "message_tool_only",
1586+
forceMessageTool: shouldForceMessageTool(params),
15871587
enableHeartbeatTool: params.trigger === "heartbeat",
15881588
forceHeartbeatTool: params.trigger === "heartbeat",
15891589
onYield: (message) => {
@@ -1617,6 +1617,10 @@ async function buildDynamicTools(input: DynamicToolBuildParams) {
16171617
});
16181618
}
16191619

1620+
function shouldForceMessageTool(params: EmbeddedRunAttemptParams): boolean {
1621+
return params.sourceReplyDeliveryMode === "message_tool_only";
1622+
}
1623+
16201624
function shouldProjectMirroredHistoryForCodexStart(params: {
16211625
startupBinding: CodexAppServerThreadBinding | undefined;
16221626
dynamicToolsFingerprint: string;
@@ -1983,6 +1987,7 @@ export const __testing = {
19831987
buildDynamicTools,
19841988
filterToolsForVisionInputs,
19851989
handleDynamicToolCallWithTimeout,
1990+
shouldForceMessageTool,
19861991
setOpenClawCodingToolsFactoryForTests(factory: OpenClawCodingToolsFactory): void {
19871992
openClawCodingToolsFactoryForTests = factory;
19881993
},

0 commit comments

Comments
 (0)