|
1 | 1 | // Codex tests cover dynamic tool execution plugin behavior. |
2 | | -import { |
3 | | - embeddedAgentLog, |
4 | | - type EmbeddedRunAttemptParamsV2 as EmbeddedRunAttemptParams, |
5 | | -} from "openclaw/plugin-sdk/agent-harness-runtime"; |
| 2 | +import type { EmbeddedRunAttemptParamsV2 as EmbeddedRunAttemptParams } from "openclaw/plugin-sdk/agent-harness-runtime"; |
6 | 3 | import { afterEach, describe, expect, it, vi } from "vitest"; |
7 | 4 | import { |
8 | 5 | handleDynamicToolCallWithTimeout, |
@@ -359,6 +356,7 @@ describe("dynamic tool execution helpers", () => { |
359 | 356 | observeToolTerminal: () => ({ |
360 | 357 | executionStarted: true, |
361 | 358 | sideEffectEvidence: true, |
| 359 | + effectReceipt: { state: "uncertain" as const }, |
362 | 360 | }), |
363 | 361 | onFallbackSelected, |
364 | 362 | onTimeout, |
@@ -437,6 +435,7 @@ describe("dynamic tool execution helpers", () => { |
437 | 435 | const observeToolTerminal = vi.fn(() => ({ |
438 | 436 | executionStarted: false, |
439 | 437 | sideEffectEvidence: false, |
| 438 | + effectReceipt: { state: "uncertain" as const }, |
440 | 439 | })); |
441 | 440 | const response = handleDynamicToolCallWithTimeout({ |
442 | 441 | call: { |
@@ -479,6 +478,7 @@ describe("dynamic tool execution helpers", () => { |
479 | 478 | text: "hello", |
480 | 479 | }, |
481 | 480 | sideEffectEvidence: false, |
| 481 | + effectReceipt: { state: "uncertain" as const }, |
482 | 482 | }), |
483 | 483 | ); |
484 | 484 | const response = handleDynamicToolCallWithTimeout({ |
@@ -826,100 +826,6 @@ describe("dynamic tool execution helpers", () => { |
826 | 826 | expect(onAgentToolResult).toHaveBeenCalledOnce(); |
827 | 827 | }); |
828 | 828 |
|
829 | | - it("logs process poll timeout context separately from session idle", async () => { |
830 | | - vi.useFakeTimers(); |
831 | | - const warn = vi.spyOn(embeddedAgentLog, "warn").mockImplementation(() => undefined); |
832 | | - const response = handleDynamicToolCallWithTimeout({ |
833 | | - call: { |
834 | | - threadId: "thread-1", |
835 | | - turnId: "turn-1", |
836 | | - callId: "call-timeout", |
837 | | - namespace: null, |
838 | | - tool: "process", |
839 | | - arguments: { action: "poll", sessionId: "process-session", timeout: 30_000 }, |
840 | | - }, |
841 | | - toolBridge: { |
842 | | - handleToolCall: vi.fn(() => new Promise<never>(() => {})), |
843 | | - }, |
844 | | - signal: new AbortController().signal, |
845 | | - timeoutMs: 1, |
846 | | - observeToolTerminal: () => ({ |
847 | | - executionStarted: true, |
848 | | - executedArguments: { action: "poll", sessionId: "adjusted-session" }, |
849 | | - sideEffectEvidence: true, |
850 | | - }), |
851 | | - }); |
852 | | - |
853 | | - await vi.advanceTimersByTimeAsync(1); |
854 | | - |
855 | | - await expect(response).resolves.toEqual({ |
856 | | - success: false, |
857 | | - contentItems: [ |
858 | | - { |
859 | | - type: "inputText", |
860 | | - text: "OpenClaw dynamic tool call timed out after 1ms while waiting for process action=poll sessionId=process-session. This is a tool RPC timeout, not a session idle timeout.", |
861 | | - }, |
862 | | - ], |
863 | | - }); |
864 | | - await expect(response).resolves.toMatchObject({ executionStarted: true }); |
865 | | - await expect(response).resolves.toMatchObject({ |
866 | | - executedArguments: { action: "poll", sessionId: "adjusted-session" }, |
867 | | - }); |
868 | | - expect(warn).toHaveBeenCalledWith("codex dynamic tool call timed out", { |
869 | | - tool: "process", |
870 | | - toolCallId: "call-timeout", |
871 | | - threadId: "thread-1", |
872 | | - turnId: "turn-1", |
873 | | - timeoutMs: 1, |
874 | | - timeoutKind: "codex_dynamic_tool_rpc", |
875 | | - processAction: "poll", |
876 | | - processSessionId: "process-session", |
877 | | - processRequestedTimeoutMs: 30_000, |
878 | | - consoleMessage: |
879 | | - "codex process tool timeout: action=poll sessionId=process-session toolTimeoutMs=1 requestedWaitMs=30000; per-tool-call watchdog, not session idle; repeated lines usually mean process-poll retry churn, not model progress", |
880 | | - }); |
881 | | - }); |
882 | | - |
883 | | - it("does not split surrogate pairs when truncating timeout log fields", async () => { |
884 | | - vi.useFakeTimers(); |
885 | | - const warn = vi.spyOn(embeddedAgentLog, "warn").mockImplementation(() => undefined); |
886 | | - const action = `${"a".repeat(156)}😀tail`; |
887 | | - const sessionId = `${"s".repeat(156)}😀tail`; |
888 | | - const response = handleDynamicToolCallWithTimeout({ |
889 | | - call: { |
890 | | - threadId: "thread-1", |
891 | | - turnId: "turn-1", |
892 | | - callId: "call-utf16-log-field", |
893 | | - namespace: null, |
894 | | - tool: "process", |
895 | | - arguments: { action, sessionId, timeout: 30_000 }, |
896 | | - }, |
897 | | - toolBridge: { |
898 | | - handleToolCall: vi.fn(() => new Promise<never>(() => {})), |
899 | | - }, |
900 | | - signal: new AbortController().signal, |
901 | | - timeoutMs: 1, |
902 | | - }); |
903 | | - |
904 | | - await vi.advanceTimersByTimeAsync(1); |
905 | | - |
906 | | - const result = await response; |
907 | | - const firstResultItem = result.contentItems[0]; |
908 | | - const resultText = firstResultItem?.type === "inputText" ? firstResultItem.text : ""; |
909 | | - const [, details] = warn.mock.calls[0] ?? []; |
910 | | - const highSurrogate = String.fromCharCode(0xd83d); |
911 | | - |
912 | | - expect(result.success).toBe(false); |
913 | | - expect(details).toMatchObject({ |
914 | | - processAction: `${"a".repeat(156)}...`, |
915 | | - processSessionId: `${"s".repeat(156)}...`, |
916 | | - }); |
917 | | - expect(resultText).not.toContain(highSurrogate); |
918 | | - expect(String((details as Record<string, unknown>).consoleMessage)).not.toContain( |
919 | | - highSurrogate, |
920 | | - ); |
921 | | - }); |
922 | | - |
923 | 829 | it("keeps async-start metadata on internal dynamic tool progress only", () => { |
924 | 830 | const response: CodexDynamicToolCallResponse = { |
925 | 831 | contentItems: [{ type: "inputText", text: "Background task started." }], |
|
0 commit comments