Q98: external calls have a time limit and stop with the run

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-08 16:12:45 -04:00
1 parent 989127bed3
commit 552dfcb6ce
4 files changed
+113 -28

No files matched your search

+20 -1
View File
@@ -8,6 +8,7 @@ const requested: string[] = [];
const written: string[] = [];
const pages = new Map<string, Record<string, unknown>>();
const executions = new Map<string, Record<string, unknown>>();
const aborted: string[] = [];
vi.mock("electron", () => ({
net: {
@@ -15,9 +16,10 @@ vi.mock("electron", () => ({
const request = new EventEmitter() as EventEmitter & { setHeader: () => void; write: (body: string) => void; end: () => void; abort: () => void };
request.setHeader = () => undefined;
request.write = (body: string) => { written.push(`${url} ${body}`); };
request.abort = () => undefined;
request.abort = () => { aborted.push(url); };
request.end = () => {
requested.push(url);
if (url.includes("/tools/execute/GITHUB_HANG")) return;
const query = new URL(url).searchParams;
const page = url.includes("/tools/execute/") ? executions.get(url.split("/tools/execute/")[1]) ?? { data: { number: 42 }, error: null, successful: true } : pages.get(`${query.get("toolkit_slug")}:${query.get("cursor") ?? ""}`);
const response = new EventEmitter() as EventEmitter & { statusCode: number };
@@ -54,6 +56,23 @@ describe("a toolkit's tools are all listed", () => {
});
});
describe("a Composio call that never answers", () => {
test("is given up after its time limit and its request is aborted", async () => {
vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
try {
const pending = new ComposioClient("ak_hang").executeTool({ toolName: "GITHUB_HANG", arguments: {}, userId: "u" });
const outcome = pending.then(() => "answered", (error: Error) => error.message);
await vi.advanceTimersByTimeAsync(119_000);
expect(aborted.some((url) => url.includes("GITHUB_HANG"))).toBe(false);
await vi.advanceTimersByTimeAsync(1_000);
expect(await outcome).toBe("Composio API POST https://backend.composio.dev/api/v3/tools/execute/GITHUB_HANG gave no answer within 120s.");
expect(aborted.some((url) => url.includes("GITHUB_HANG"))).toBe(true);
} finally {
vi.useRealTimers();
}
});
});
describe("agents reach every action through search and run", () => {
const vault = { encryptSecret: (secret: string) => Buffer.from(secret, "utf8"), decryptSecret: (ciphertext: Buffer) => ciphertext.toString("utf8") };