Fix tests

This commit is contained in:
Joshen Lim committed 2025-09-25 15:23:59 +08:00
1 parent b9e50838ee
commit a7bddc8bb0
2 files changed
+10 -8

No files matched your search

@@ -8,7 +8,7 @@ import {
createAssistantMessageWithMultipleTools,
createLongConversation,
} from '../test-fixtures'
import { sanitizeMessagePart } from './tool-sanitizer'
import { NO_DATA_PERMISSIONS, sanitizeMessagePart } from './tool-sanitizer'
describe('messages are sanitized based on opt-in level', () => {
test('messages are sanitized at disabled level', () => {
@@ -34,7 +34,7 @@ describe('messages are sanitized based on opt-in level', () => {
})
const output = (processedMessages[0].parts[1] as ToolUIPart).output
expect(output).toMatch(/result is not shared/)
expect(output).toMatch(NO_DATA_PERMISSIONS)
})
test('messages are sanitized at schema level', () => {
@@ -60,7 +60,7 @@ describe('messages are sanitized based on opt-in level', () => {
})
const output = (processedMessages[0].parts[1] as ToolUIPart).output
expect(output).toMatch(/result is not shared/)
expect(output).toMatch(NO_DATA_PERMISSIONS)
})
test('messages are sanitized at schema and log level', () => {
@@ -86,7 +86,7 @@ describe('messages are sanitized based on opt-in level', () => {
})
const output = (processedMessages[0].parts[1] as ToolUIPart).output
expect(output).toMatch(/result is not shared/)
expect(output).toMatch(NO_DATA_PERMISSIONS)
})
test('messages are not sanitized at data level', () => {
@@ -137,7 +137,7 @@ describe('messages are sanitized based on opt-in level', () => {
parts.forEach((part) => {
if (part.type.startsWith('tool')) {
const tool = part as ToolUIPart
expect(tool.output).toMatch(/result is not shared/)
expect(tool.output).toMatch(NO_DATA_PERMISSIONS)
}
})
})
@@ -166,7 +166,7 @@ describe('messages are sanitized based on opt-in level', () => {
parts.forEach((part) => {
if (part.type.startsWith('tool')) {
const tool = part as ToolUIPart
expect(tool.output).toMatch(/result is not shared/)
expect(tool.output).toMatch(NO_DATA_PERMISSIONS)
}
})
}
+4 -2
View File
@@ -9,6 +9,9 @@ interface ToolSanitizer {
sanitize: <Tool extends ToolUIPart>(tool: Tool, optInLevel: AiOptInLevel) => Tool
}
export const NO_DATA_PERMISSIONS =
'The query was executed and the user has viewed the results but decided not to share in the conversation due to permission levels. Continue with your plan unless instructed to interpret the result.'
const executeSqlSanitizer: ToolSanitizer = {
toolName: 'execute_sql',
sanitize: (tool, optInLevel) => {
@@ -17,8 +20,7 @@ const executeSqlSanitizer: ToolSanitizer = {
if (optInLevel !== 'schema_and_log_and_data') {
if (Array.isArray(output)) {
sanitizedOutput =
'The query was executed and the user has viewed the results but decided not to share in the conversation due to permission levels. Continue with your plan unless instructed to interpret the result.'
sanitizedOutput = NO_DATA_PERMISSIONS
}
} else {
sanitizedOutput = output