UNPKG

@mastra/core

Version:
35 lines • 2.13 kB
import type { Processor, ProcessAPIErrorArgs, ProcessAPIErrorResult, ProcessOutputStepArgs, ProcessorMessageResult } from './index.js'; /** * Retries once after a cybersecurity-safeguard refusal from OpenAI or Anthropic. * * Provider cyber safeguards can refuse ordinary repository work, often partway * through a long agentic loop. These refusals are frequently false positives, * and nudging the model to continue usually gets past them. This processor * retries the step a single time with that nudge; if the retried step is * refused again, the refusal is treated as genuine. * * - OpenAI refuses with a `cyber_policy` error ("This content was flagged for * possible cybersecurity risk..."), handled in `processAPIError`, which * appends a `continue` system reminder. * - Anthropic stops the response with a `cyber` classifier refusal (finish * reason `content-filter`), handled in `processOutputStep`. The refused step * is rolled back and the retry appends the same `continue` system reminder. * * Register it in both lanes: `errorProcessors` for OpenAI refusals (an agent * only runs `processAPIError` for error processors) and `outputProcessors` for * Anthropic refusals. In `errorProcessors`, place it before * {@link StreamErrorRetryProcessor}, which would otherwise spend the retry * resending the unchanged request. Output-step retries count against * `maxProcessorRetries`, which is not given an implicit default the way the * error lane is, so set it explicitly or the Anthropic retry is treated as an * abort. * * @see https://developers.openai.com/api/docs/guides/safety-checks/cybersecurity */ export declare class CyberRefusalHandler implements Processor<'cyber-refusal-handler'> { readonly id: 'cyber-refusal-handler'; readonly name = "Cyber Refusal Handler"; processAPIError({ error, retryCount, sendSignal }: ProcessAPIErrorArgs): Promise<ProcessAPIErrorResult | void>; processOutputStep({ finishReason, providerMetadata, retryCount, abort, messageList, }: ProcessOutputStepArgs): ProcessorMessageResult; } //# sourceMappingURL=cyber-refusal-handler.d.ts.map