Skip to content

Commit a9319b8

Browse files
fix(server): agent clones are no longer cut off after 2 minutes
t3_project_clone used the 120s deadline meant for the synchronous clone RPC, so an agent's clone of a large or slow remote was killed mid-transfer. The MCP clone now runs without a deadline, like the tracked UI clone; the provider's MCP call budget and an aborted call still interrupt git. A clone that hits its deadline now says it timed out instead of showing git's last remote line. runClone applies the deadline itself, so the timeout is a distinct failure and never triggers the SSH-to-HTTPS retry. Fixes #27567 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 787ed2b commit a9319b8

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

‎apps/server/src/mcp/toolkits/project/handlers.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
352352
(input) =>
353353
Effect.gen(function* () {
354354
const repositories = yield* Repositories.SourceControlRepositoryService;
355-
return yield* repositories.cloneRepository(input).pipe(
355+
// Agents' MCP calls have their own long budget, and an aborted call interrupts git.
356+
return yield* repositories.cloneRepository(input, { timeoutMs: null }).pipe(
356357
Effect.mapError(
357358
(error) =>
358359
new OrchestratorMcpFailure({

‎apps/server/src/sourceControl/SourceControlRepositoryService.ts‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as Context from "effect/Context";
2+
import * as Duration from "effect/Duration";
23
import * as Effect from "effect/Effect";
34
import * as FileSystem from "effect/FileSystem";
45
import * as Layer from "effect/Layer";
@@ -348,12 +349,15 @@ export const make = Effect.gen(function* () {
348349
};
349350
// Git misreads @ in a pathless URL's query as userinfo and echoes its suffix as the host.
350351
const normalizedCloneUrl = cloneUrl.replace(/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)\?/i, "$1/?");
351-
yield* git
352+
const provider = input.provider ?? SourceControlProviderKind.make("unknown");
353+
const timeoutMs = options?.timeoutMs === undefined ? CLONE_TIMEOUT_MS : options.timeoutMs;
354+
const clone = git
352355
.execute({
353356
operation: "SourceControlRepositoryService.cloneRepository",
354357
cwd: path.dirname(destinationPath),
355358
args: ["clone", "--progress", "--", normalizedCloneUrl, path.basename(destinationPath)],
356-
timeoutMs: options?.timeoutMs === undefined ? CLONE_TIMEOUT_MS : options.timeoutMs,
359+
// The deadline is applied below so a timeout is reported as one, not as git's last line.
360+
timeoutMs: null,
357361
// Buffered output is unused and progress can be huge; cap it while retaining line callbacks.
358362
maxOutputBytes: 256 * 1024,
359363
appendTruncationMarker: true,
@@ -366,7 +370,7 @@ export const make = Effect.gen(function* () {
366370
(cause) =>
367371
new SourceControlRepositoryError({
368372
operation: "cloneRepository",
369-
provider: input.provider ?? SourceControlProviderKind.make("unknown"),
373+
provider,
370374
detail:
371375
stderrTail.length > 0
372376
? stderrTail.join(" ")
@@ -375,6 +379,21 @@ export const make = Effect.gen(function* () {
375379
}),
376380
),
377381
);
382+
if (timeoutMs === null) return yield* clone;
383+
// Interrupting the clone closes the scope that owns git, which kills it.
384+
return yield* clone.pipe(
385+
Effect.timeoutOrElse({
386+
duration: timeoutMs,
387+
orElse: () =>
388+
Effect.fail(
389+
new SourceControlRepositoryError({
390+
operation: "cloneRepository",
391+
provider,
392+
detail: `The clone timed out after ${Duration.format(Duration.millis(timeoutMs))}.`,
393+
}),
394+
),
395+
}),
396+
);
378397
});
379398

380399
const cloneRepository = Effect.fn("SourceControlRepositoryService.cloneRepository")(function* (

0 commit comments

Comments
 (0)