@@ -27,11 +27,8 @@ import {
2727 sendMessageAndWait ,
2828 extractTextFromEvents ,
2929 writeFileViaBash ,
30+ configureTestRetries ,
3031 HAIKU_MODEL ,
31- TEST_TIMEOUT_LOCAL_MS ,
32- TEST_TIMEOUT_SSH_MS ,
33- STREAM_TIMEOUT_LOCAL_MS ,
34- STREAM_TIMEOUT_SSH_MS ,
3532} from "./helpers" ;
3633import {
3734 isDockerAvailable ,
@@ -56,6 +53,13 @@ if (shouldRunIntegrationTests()) {
5653 validateApiKeys ( [ "ANTHROPIC_API_KEY" ] ) ;
5754}
5855
56+ // Increased timeouts for file editing tests - these tests require LLM tool calls
57+ // which can be slow depending on API response times
58+ const STREAM_TIMEOUT_MS = 30000 ; // Stream timeout (was 15s)
59+ const SSH_STREAM_TIMEOUT_MS = 45000 ; // SSH stream timeout (was 25s)
60+ const LOCAL_TEST_TIMEOUT_MS = 45000 ; // Test timeout (was 25s)
61+ const SSH_TEST_TIMEOUT_MS = 90000 ; // SSH test timeout (was 60s)
62+
5963// SSH server config (shared across all SSH tests)
6064let sshConfig : SSHServerConfig | undefined ;
6165
@@ -64,6 +68,9 @@ let sshConfig: SSHServerConfig | undefined;
6468// ============================================================================
6569
6670describeIntegration ( "Runtime File Editing Tools" , ( ) => {
71+ // Enable retries in CI for flaky API tests
72+ configureTestRetries ( 3 ) ;
73+
6774 beforeAll ( async ( ) => {
6875 // Check if Docker is available (required for SSH tests)
6976 if ( ! ( await isDockerAvailable ( ) ) ) {
@@ -136,8 +143,7 @@ describeIntegration("Runtime File Editing Tools", () => {
136143 await writeFileViaBash ( env , workspaceId , testFileName , testContent ) ;
137144
138145 // Ask AI to read the file (explicitly request file_read tool)
139- const streamTimeout =
140- type === "ssh" ? STREAM_TIMEOUT_SSH_MS : STREAM_TIMEOUT_LOCAL_MS ;
146+ const streamTimeout = type === "ssh" ? SSH_STREAM_TIMEOUT_MS : STREAM_TIMEOUT_MS ;
141147 const readEvents = await sendMessageAndWait (
142148 env ,
143149 workspaceId ,
@@ -170,7 +176,7 @@ describeIntegration("Runtime File Editing Tools", () => {
170176 await cleanupTempGitRepo ( tempGitRepo ) ;
171177 }
172178 } ,
173- type === "ssh" ? TEST_TIMEOUT_SSH_MS : TEST_TIMEOUT_LOCAL_MS
179+ type === "ssh" ? SSH_TEST_TIMEOUT_MS : LOCAL_TEST_TIMEOUT_MS
174180 ) ;
175181
176182 test . concurrent (
@@ -206,8 +212,7 @@ describeIntegration("Runtime File Editing Tools", () => {
206212 await writeFileViaBash ( env , workspaceId , testFileName , testContent ) ;
207213
208214 // Ask AI to replace text (explicitly request file_edit_replace_string tool)
209- const streamTimeout =
210- type === "ssh" ? STREAM_TIMEOUT_SSH_MS : STREAM_TIMEOUT_LOCAL_MS ;
215+ const streamTimeout = type === "ssh" ? SSH_STREAM_TIMEOUT_MS : STREAM_TIMEOUT_MS ;
211216 const replaceEvents = await sendMessageAndWait (
212217 env ,
213218 workspaceId ,
@@ -246,7 +251,7 @@ describeIntegration("Runtime File Editing Tools", () => {
246251 await cleanupTempGitRepo ( tempGitRepo ) ;
247252 }
248253 } ,
249- type === "ssh" ? TEST_TIMEOUT_SSH_MS : TEST_TIMEOUT_LOCAL_MS
254+ type === "ssh" ? SSH_TEST_TIMEOUT_MS : LOCAL_TEST_TIMEOUT_MS
250255 ) ;
251256
252257 test . concurrent (
@@ -282,8 +287,7 @@ describeIntegration("Runtime File Editing Tools", () => {
282287 await writeFileViaBash ( env , workspaceId , testFileName , testContent ) ;
283288
284289 // Ask AI to insert text (explicitly request file_edit tool usage)
285- const streamTimeout =
286- type === "ssh" ? STREAM_TIMEOUT_SSH_MS : STREAM_TIMEOUT_LOCAL_MS ;
290+ const streamTimeout = type === "ssh" ? SSH_STREAM_TIMEOUT_MS : STREAM_TIMEOUT_MS ;
287291 const insertEvents = await sendMessageAndWait (
288292 env ,
289293 workspaceId ,
@@ -323,7 +327,7 @@ describeIntegration("Runtime File Editing Tools", () => {
323327 await cleanupTempGitRepo ( tempGitRepo ) ;
324328 }
325329 } ,
326- type === "ssh" ? TEST_TIMEOUT_SSH_MS : TEST_TIMEOUT_LOCAL_MS
330+ type === "ssh" ? SSH_TEST_TIMEOUT_MS : LOCAL_TEST_TIMEOUT_MS
327331 ) ;
328332
329333 test . concurrent (
@@ -359,8 +363,7 @@ describeIntegration("Runtime File Editing Tools", () => {
359363 await writeFileViaBash ( env , workspaceId , relativeTestFile , testContent ) ;
360364
361365 // Now edit the file using a relative path
362- const streamTimeout =
363- type === "ssh" ? STREAM_TIMEOUT_SSH_MS : STREAM_TIMEOUT_LOCAL_MS ;
366+ const streamTimeout = type === "ssh" ? SSH_STREAM_TIMEOUT_MS : STREAM_TIMEOUT_MS ;
364367 const editEvents = await sendMessageAndWait (
365368 env ,
366369 workspaceId ,
@@ -408,7 +411,7 @@ describeIntegration("Runtime File Editing Tools", () => {
408411 await cleanupTempGitRepo ( tempGitRepo ) ;
409412 }
410413 } ,
411- type === "ssh" ? TEST_TIMEOUT_SSH_MS : TEST_TIMEOUT_LOCAL_MS
414+ type === "ssh" ? SSH_TEST_TIMEOUT_MS : LOCAL_TEST_TIMEOUT_MS
412415 ) ;
413416 }
414417 ) ;
0 commit comments