(userContent: Anthropic.Messages.ContentBlockParam[])
| 2412 | // Task Loop |
| 2413 | |
| 2414 | private async initiateTaskLoop(userContent: Anthropic.Messages.ContentBlockParam[]): Promise<void> { |
| 2415 | // Kicks off the checkpoints initialization process in the background. |
| 2416 | // `getCheckpointService` wraps its full body in a try/catch and returns |
| 2417 | // `undefined` on failure (see src/core/checkpoints/index.ts), so the |
| 2418 | // returned promise cannot reject. `void` is sufficient — no `.catch` |
| 2419 | // arm needed. |
| 2420 | void getCheckpointService(this) |
| 2421 | |
| 2422 | let nextUserContent = userContent |
| 2423 | let includeFileDetails = true |
| 2424 | |
| 2425 | this.emit(RooCodeEventName.TaskStarted) |
| 2426 | |
| 2427 | while (!this.abort) { |
| 2428 | const didEndLoop = await this.recursivelyMakeClineRequests(nextUserContent, includeFileDetails) |
| 2429 | includeFileDetails = false // We only need file details the first time. |
| 2430 | |
| 2431 | // The way this agentic loop works is that cline will be given a |
| 2432 | // task that he then calls tools to complete. Unless there's an |
| 2433 | // attempt_completion call, we keep responding back to him with his |
| 2434 | // tool's responses until he either attempt_completion or does not |
| 2435 | // use anymore tools. If he does not use anymore tools, we ask him |
| 2436 | // to consider if he's completed the task and then call |
| 2437 | // attempt_completion, otherwise proceed with completing the task. |
| 2438 | // There is a MAX_REQUESTS_PER_TASK limit to prevent infinite |
| 2439 | // requests, but Cline is prompted to finish the task as efficiently |
| 2440 | // as he can. |
| 2441 | |
| 2442 | if (didEndLoop) { |
| 2443 | // For now a task never 'completes'. This will only happen if |
| 2444 | // the user hits max requests and denies resetting the count. |
| 2445 | break |
| 2446 | } else { |
| 2447 | nextUserContent = [{ type: "text", text: formatResponse.noToolsUsed() }] |
| 2448 | } |
| 2449 | } |
| 2450 | } |
| 2451 | |
| 2452 | public async recursivelyMakeClineRequests( |
| 2453 | userContent: Anthropic.Messages.ContentBlockParam[], |
no test coverage detected