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 @@ -3,7 +3,7 @@
* Will be deleted or merged.
*/

import * as path from 'path'

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 "path"

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 "path"
import {
ChatTriggerType,
CodeWhispererStreamingServiceException,
Expand Down Expand Up @@ -524,6 +524,7 @@
let currentRequestInput = { ...initialRequestInput }
let finalResult: Result<AgenticChatResultWithMetadata, string> | null = null
let iterationCount = 0
let shouldDisplayMessage = true
metric.recordStart()

while (iterationCount < maxAgentLoopIterations) {
Expand Down Expand Up @@ -574,8 +575,10 @@
userIntent: currentMessage.userInputMessage?.userIntent,
origin: currentMessage.userInputMessage?.origin,
userInputMessageContext: currentMessage.userInputMessage?.userInputMessageContext,
shouldDisplayMessage: shouldDisplayMessage,
})
}
shouldDisplayMessage = true

// Phase 4: Response Processing
const result = await this.#processGenerateAssistantResponseResponseWithTimeout(
Expand Down Expand Up @@ -620,6 +623,7 @@
name: result.data!.toolUses[k].name,
input: result.data!.toolUses[k].input,
})),
shouldDisplayMessage: shouldDisplayMessage,
})
} else {
this.#features.logging.warn('No ChatResult body in response, skipping adding to history')
Expand All @@ -641,6 +645,7 @@
toolResults = await this.#processToolUses(pendingToolUses, chatResultStream, session, tabId, token)
if (toolResults.some(toolResult => this.#shouldSendBackErrorContent(toolResult))) {
content = 'There was an error processing one or more tool uses. Try again, do not apologize.'
shouldDisplayMessage = false
}
metric.setDimension('cwsprChatConversationType', 'AgenticChatWithToolUse')
} else {
Expand All @@ -653,6 +658,7 @@
if (result.error.startsWith('ToolUse input is invalid JSON:')) {
content =
'Your toolUse input is incomplete because it is too large. Break this task down into multiple tool uses with smaller input. Do not apologize.'
shouldDisplayMessage = false
}
}
currentRequestInput = this.#updateRequestInputWithToolResults(currentRequestInput, toolResults, content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class TabBarController {
async restoreTab(selectedTab?: Tab | null) {
if (selectedTab) {
const messages = selectedTab.conversations.flatMap((conv: Conversation) =>
conv.messages.flatMap(msg => messageToChatMessage(msg))
conv.messages.filter(msg => msg.shouldDisplayMessage != false).flatMap(msg => messageToChatMessage(msg))
)

const { tabId } = await this.#features.chat.openTab({ newTabOptions: { data: { messages } } })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
TabType,
updateOrCreateConversation,
} from './util'
import * as crypto from 'crypto'

Check warning on line 18 in server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/chatDb/chatDb.ts

View workflow job for this annotation

GitHub Actions / Test

Do not import Node.js builtin module "crypto"

Check warning on line 18 in server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/chatDb/chatDb.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 19 in server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/chatDb/chatDb.ts

View workflow job for this annotation

GitHub Actions / Test

Do not import Node.js builtin module "path"

Check warning on line 19 in server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/chatDb/chatDb.ts

View workflow job for this annotation

GitHub Actions / Test (Windows)

Do not import Node.js builtin module "path"
import { Features } from '@aws/language-server-runtimes/server-interface/server'
import { ConversationItemGroup } from '@aws/language-server-runtimes/protocol'
import { ChatMessage, ToolResultStatus } from '@amzn/codewhisperer-streaming'
Expand Down Expand Up @@ -313,8 +313,9 @@

const tabData = historyId ? tabCollection.findOne({ historyId }) : undefined
const tabTitle =
(message.type === 'prompt' && message.body.trim().length > 0 ? message.body : tabData?.title) ||
'Amazon Q Chat'
(message.type === 'prompt' && message.shouldDisplayMessage !== false && message.body.trim().length > 0
? message.body
: tabData?.title) || 'Amazon Q Chat'
message = this.formatChatHistoryMessage(message)
if (tabData) {
this.#features.logging.log(`Updating existing tab with historyId=${historyId}`)
Expand Down
Loading