> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ko/llms.txt # PrefillErrorHandler 그만큼`PrefillErrorHandler`은**오류 프로세서**보조자 응답 미리 채우기 오류를 처리합니다. 이 오류는 대화가 보조 메시지로 끝나고 Model이 보조 응답을 미리 채우는 것으로 해석하기 때문에 요청을 거부할 때 발생합니다. 오류가 감지되면 프로세서는 `continue`를 콘텐츠로 포함하는 숨겨진 `system-reminder` 신호를 전송하여 재시도를 지시합니다. 알림은 신호 메타데이터로 유지되므로 재시도 재구성 및 원시 기록에서 계속 사용할 수 있지만, 표준 UI용 메시지 변환에서는 숨겨집니다. Mastra가 어시스턴트 프리필 거부(예: Anthropic의 "assistant message prefill" 오류 및 Qwen/llama.cpp의 "assistant response prefill is incompatible with `enable_thinking`" 오류)에서 복구하도록 하려면 이 프로세서를 `errorProcessors`에 추가하세요. ## 작동 원리 1. 알려진 어시스턴트 프리필 거부 메시지와 함께 LLM API 호출이 실패합니다. 2. `PrefillErrorHandler`가 첫 번째 재시도인지 확인합니다. 3. `continue`를 콘텐츠로 포함하는 숨겨진 `system-reminder` 신호를 보냅니다. 4. 수정된 메시지로 LLM 호출을 재시도해야 함을 나타내기 위해 `{ retry: true }`를 반환합니다. 이제 프로세서는 대화가 현재 보조 메시지로 끝나는지 다시 확인하는 대신 API 거부 자체에 반응합니다. 이는 후행 메시지 형태가 이미 업스트림으로 변환된 경우에도 공급자가 사전 채우기 의미 체계에 대한 요청을 거부하는 경우에 탄력성을 갖게 합니다. ## 사용예 어시스턴트 프리필 실패를 재시도해야 하는 모든 Agent의 `errorProcessors`에 `PrefillErrorHandler`를 추가하세요. ```typescript import { Agent } from '@mastra/core/agent' import { PrefillErrorHandler } from '@mastra/core/processors' export const agent = new Agent({ id: 'my-agent', name: 'my-agent', instructions: 'You are a helpful assistant.', model: 'anthropic/claude-opus-4-7', errorProcessors: [new PrefillErrorHandler()], }) ``` 사용자 정의 복구 동작을 원하는 경우 자체 오류 프로세서를 제공하십시오.`processAPIError` method: ```typescript import { Agent } from '@mastra/core/agent' import type { Processor } from '@mastra/core/processors' const customErrorHandler: Processor = { id: 'custom-prefill-error-handler', processAPIError({ error, messageList, retryCount }) { // Your custom logic here }, } export const agent = new Agent({ id: 'my-agent', name: 'my-agent', instructions: 'You are a helpful assistant.', model: 'anthropic/claude-opus-4-7', errorProcessors: [customErrorHandler], }) ``` ## 생성자 매개변수 그만큼`PrefillErrorHandler` takes no constructor parameters. ## 속성 **id** (`'prefill-error-handler'`): 프로세서 식별자입니다. **name** (`'Prefill Error Handler'`): 프로세서 표시 이름입니다. **processAPIError** (`(args: ProcessAPIErrorArgs) => ProcessAPIErrorResult | void`): 알려진 assistant-prefill 오류가 발생하면 숨겨진 시스템 알림 신호를 전송하고 재시도를 지시합니다. 첫 번째 재시도에서만 실행됩니다. ## 관련된 - [프로세서 인터페이스](https://mastra.zisheng.pro/ko/reference/processors/processor-interface) - [난간](https://mastra.zisheng.pro/ko/docs/agents/guardrails)