Skip to content

Commit dfa70f6

Browse files
claude-code-bestdeepseek-v4-pro
andcommitted
refactor: remove CYBER_RISK_MITIGATION_REMINDER from FileReadTool
Co-Authored-By: deepseek-v4-pro <deepseek-ai@claude-code-best.win>
1 parent e637b4f commit dfa70f6

2 files changed

Lines changed: 16 additions & 24 deletions

File tree

packages/builtin-tools/src/tools/FileReadTool/FileReadTool.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import { lazySchema } from 'src/utils/lazySchema.js'
5252
import { logError } from 'src/utils/log.js'
5353
import { isAutoMemFile } from 'src/utils/memoryFileDetection.js'
5454
import { createUserMessage } from 'src/utils/messages.js'
55-
import { getCanonicalName, getMainLoopModel } from 'src/utils/model/model.js'
5655
import {
5756
mapNotebookCellsToToolResult,
5857
readNotebook,
@@ -409,9 +408,7 @@ export const FileReadTool = buildTool({
409408
renderToolResultMessage,
410409
// UI.tsx:140 — ALL types render summary chrome only: "Read N lines",
411410
// "Read image (42KB)". Never the content itself. The model-facing
412-
// serialization (below) sends content + CYBER_RISK_MITIGATION_REMINDER
413-
// + line prefixes; UI shows none of it. Nothing to index. Caught by
414-
// the render-fidelity test when this initially claimed file.content.
411+
// serialization (below) sends content + line prefixes; UI shows none of it.
415412
extractSearchText() {
416413
return ''
417414
},
@@ -694,12 +691,7 @@ export const FileReadTool = buildTool({
694691
let content: string
695692

696693
if (data.file.content) {
697-
content =
698-
memoryFileFreshnessPrefix(data) +
699-
formatFileLines(data.file) +
700-
(shouldIncludeFileReadMitigation()
701-
? CYBER_RISK_MITIGATION_REMINDER
702-
: '')
694+
content = memoryFileFreshnessPrefix(data) + formatFileLines(data.file)
703695
} else {
704696
// Determine the appropriate warning message
705697
content =
@@ -727,17 +719,6 @@ function formatFileLines(file: { content: string; startLine: number }): string {
727719
return addLineNumbers(file)
728720
}
729721

730-
export const CYBER_RISK_MITIGATION_REMINDER =
731-
'\n\n<system-reminder>\nWhenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.\n</system-reminder>\n'
732-
733-
// Models where cyber risk mitigation should be skipped
734-
const MITIGATION_EXEMPT_MODELS = new Set(['claude-opus-4-6'])
735-
736-
function shouldIncludeFileReadMitigation(): boolean {
737-
const shortName = getCanonicalName(getMainLoopModel())
738-
return !MITIGATION_EXEMPT_MODELS.has(shortName)
739-
}
740-
741722
/**
742723
* Side-channel from call() to mapToolResultToToolResultBlockParam: mtime
743724
* of auto-memory files, keyed by the `data` object identity. Avoids

src/workflow/__tests__/claudeCodeBackend.test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,20 @@ mock.module(
3333
)
3434
mock.module('src/tools.js', () => ({ assembleToolPool: () => ({ tools: [] }) }))
3535
mock.module('src/utils/messages.js', () => ({
36-
createUserMessage: (o: { content: string }) => ({
37-
role: 'user',
38-
content: o.content,
36+
// Return a shape that satisfies UserMessage consumers process-wide.
37+
// Bun's mock.module is process-global (last-write-wins), so an incomplete
38+
// mock here corrupts every later test that imports the real createUserMessage
39+
// (e.g. bridgeMessaging.test.ts's `type !== 'user'` early-exit, or
40+
// processSlashCommand.test.ts's `message.content` access). Mirror the real
41+
// shape from src/utils/messages.ts: type + message envelope + passthrough.
42+
createUserMessage: (
43+
o: {
44+
content: string
45+
} & Record<string, unknown>,
46+
) => ({
47+
type: 'user' as const,
48+
message: { role: 'user', content: o.content },
49+
...o,
3950
}),
4051
extractTextContent: () => 'agent-text',
4152
}))

0 commit comments

Comments
 (0)