> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ko/llms.txt # 시스템 Prompt 스크러버 그만큼`SystemPromptScrubber`은**출력 프로세서**보안 취약점을 유발할 수 있는 시스템 Prompt, 지침 및 기타 노출 정보를 탐지하고 처리합니다. 이 프로세서는 시스템 Prompt 유형을 식별하고 이를 처리하기 위한 유연한 전략을 제공하여 보안을 유지하는 데 도움이 됩니다. 여기에는 민감한 정보를 적절하게 삭제하기 위한 다중 수정 방법이 포함됩니다. ## 사용예 ```typescript import { SystemPromptScrubber } from '@mastra/core/processors' const processor = new SystemPromptScrubber({ model: 'openrouter/openai/gpt-oss-safeguard-20b', strategy: 'redact', redactionMethod: 'mask', includeDetections: true, lastMessageOnly: true, }) ``` ## 생성자 매개변수 **options** (`Options`): 시스템 Prompt 감지 및 처리를 위한 구성 옵션 **options.model** (`MastraModelConfig`): 감지 Agent의 Model 구성 **options.strategy** (`'block' | 'warn' | 'filter' | 'redact'`): 시스템 Prompt가 감지되었을 때의 전략: 'block'은 오류와 함께 거부하고, 'warn'은 경고를 기록하지만 통과시키며, 'filter'는 플래그가 지정된 메시지를 제거하고, 'redact'는 삭제된 버전으로 대체합니다 **options.customPatterns** (`string[]`): 시스템 Prompt를 감지할 사용자 지정 패턴(정규식 문자열) **options.includeDetections** (`boolean`): 경고에 감지 세부 정보를 포함할지 여부. 디버깅과 모니터링에 유용합니다 **options.lastMessageOnly** (`boolean`): 모든 메시지를 확인하는 대신 배치에서 가장 최근의 출력 메시지만 검사할지 여부입니다. LLM 기반 스크러빙을 최신 응답으로 제한하려면 이 옵션을 사용하세요. **options.instructions** (`string`): 감지 Agent를 위한 사용자 지정 지침입니다. 제공하지 않으면 기본 지침을 사용합니다 **options.redactionMethod** (`'mask' | 'placeholder' | 'remove'`): 시스템 Prompt의 수정 방법입니다. 'mask'는 별표로 대체하고, 'placeholder'는 자리표시자 텍스트로 대체하며, 'remove'는 완전히 제거합니다 **options.placeholderText** (`string`): redactionMethod가 'placeholder'일 때 수정에 사용할 사용자 지정 자리표시자 텍스트입니다 ## 보고 **id** (`string`): 'system-prompt-scrubber'로 설정된 프로세서 식별자입니다 **name** (`string`): 선택적 프로세서 표시 이름입니다 **processOutputStream** (`(args: { part: ChunkType; streamParts: ChunkType[]; state: Record; abort: (reason?: string) => never; tracingContext?: TracingContext }) => Promise`): 스트리밍 중 시스템 Prompt를 감지하고 처리하기 위해 스트리밍 출력 부분을 처리합니다 **processOutputResult** (`(args: { messages: MastraDBMessage[]; abort: (reason?: string) => never }) => Promise`): 비스트리밍 시나리오에서 시스템 Prompt를 감지하고 처리하기 위해 최종 출력 결과를 처리합니다 ## 확장된 사용 예 `SystemPromptScrubber`를 출력 프로세서로 사용할 때는 성능 최적화를 위해 `BatchPartsProcessor`와 함께 사용하는 것이 좋습니다. `BatchPartsProcessor`는 스트림 청크를 스크러버에 전달하기 전에 배치로 묶어 감지에 필요한 LLM 호출 횟수를 줄입니다. ```typescript import { Agent } from '@mastra/core/agent' import { BatchPartsProcessor, SystemPromptScrubber } from '@mastra/core/processors' export const agent = new Agent({ id: 'scrubbed-agent', name: 'scrubbed-agent', instructions: 'You are a helpful assistant', model: 'openai/gpt-5.6-sol', outputProcessors: [ // Batch stream parts first to reduce LLM calls new BatchPartsProcessor({ batchSize: 10, }), // Then apply system prompt detection on batched content new SystemPromptScrubber({ model: 'openrouter/openai/gpt-oss-safeguard-20b', strategy: 'redact', customPatterns: ['system prompt', 'internal instructions'], includeDetections: true, redactionMethod: 'placeholder', placeholderText: '[REDACTED]', }), ], }) ``` ## 관련된 - [난간](https://mastra.zisheng.pro/ko/docs/agents/guardrails)