Skip to content
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 @@ -88,7 +88,7 @@ import {
} from '../../constants'
import { ChatSession } from '../../clients/chat/v0/chat'
import { amazonQTabSuffix } from '../../../shared/constants'
import { OutputKind } from '../../tools/toolShared'
import { maxToolOutputCharacterLength, OutputKind } from '../../tools/toolShared'
import { ToolUtils, Tool, ToolType } from '../../tools/toolUtils'
import { ChatStream } from '../../tools/chatStream'
import { ChatHistoryStorage } from '../../storages/chatHistoryStorage'
Expand Down Expand Up @@ -667,6 +667,11 @@ export class ChatController {
requiresAcceptance: false,
})
const output = await ToolUtils.invoke(tool, chatStream)
if (output.output.content.length > maxToolOutputCharacterLength) {
throw Error(
`Tool output exceeds maximum character limit of ${maxToolOutputCharacterLength}`
)
}

toolResults.push({
content: [
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/codewhispererChat/tools/toolShared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import path from 'path'
import fs from '../../shared/fs/fs'

export const maxToolResponseSize = 30720 // 30KB
export const maxToolOutputCharacterLength = 800_000

export enum OutputKind {
Text = 'text',
Expand Down
Loading