Skip to content

fix: remove limit on agentic loop #1367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
* Will be deleted or merged.
*/

import * as crypto from 'crypto'

Check warning on line 6 in server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

View workflow job for this annotation

GitHub Actions / Test

Do not import Node.js builtin module "crypto"

Check warning on line 6 in server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

View workflow job for this annotation

GitHub Actions / Test (Windows)

Do not import Node.js builtin module "crypto"
import * as path from 'path'

Check warning on line 7 in server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

View workflow job for this annotation

GitHub Actions / Test

Do not import Node.js builtin module "path"

Check warning on line 7 in server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

View workflow job for this annotation

GitHub Actions / Test (Windows)

Do not import Node.js builtin module "path"
import {
ChatTriggerType,
CodeWhispererStreamingServiceException,
GenerateAssistantResponseCommandInput,
GenerateAssistantResponseCommandOutput,
SendMessageCommandInput,
Expand Down Expand Up @@ -114,7 +113,6 @@
import { diffLines } from 'diff'
import {
genericErrorMsg,
maxAgentLoopIterations,
loadingThresholdMs,
generateAssistantResponseInputLimit,
outputLimitExceedsPartialMsg,
Expand Down Expand Up @@ -558,7 +556,7 @@
let shouldDisplayMessage = true
metric.recordStart()

while (iterationCount < maxAgentLoopIterations) {
while (true) {
iterationCount++
this.#debug(`Agent loop iteration ${iterationCount} for conversation id:`, conversationIdentifier || '')

Expand Down Expand Up @@ -764,10 +762,6 @@
currentRequestInput = this.#updateRequestInputWithToolResults(currentRequestInput, toolResults, content)
}

if (iterationCount >= maxAgentLoopIterations) {
throw new AgenticChatError('Agent loop reached iteration limit', 'MaxAgentLoopIterations')
}

return (
finalResult || {
success: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const genericErrorMsg = 'An unexpected error occurred, check the logs for more information.'
export const maxAgentLoopIterations = 100
export const loadingThresholdMs = 2000
export const generateAssistantResponseInputLimit = 500_000
export const outputLimitExceedsPartialMsg = 'output exceeds maximum character limit of'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ type AgenticChatErrorCode =
| 'QModelResponse' // generic backend error.
| 'AmazonQServiceManager' // AmazonQServiceManager failed to initialize.
| 'FailedResult' // general error when processing tool results
| 'MaxAgentLoopIterations'
| 'InputTooLong' // too much context given to backend service.
| 'PromptCharacterLimit' // customer prompt exceeds
| 'ResponseProcessingTimeout' // response didn't finish streaming in the allowed time

export const customerFacingErrorCodes: AgenticChatErrorCode[] = [
'QModelResponse',
'MaxAgentLoopIterations',
'InputTooLong',
'PromptCharacterLimit',
]
Expand Down
Loading