mastra-ai/mastra · warning · TripWire
${tripwireChunk.payload?.reason || 'Agent tripwire triggered
Error message
${tripwireChunk.payload?.reason || 'Agent tripwire triggered'} What it means
While streaming an agent step, the workflow consumes the stream watching for tripwire chunks emitted by input/output processors. If a tripwire is detected, runAgentEntry throws a TripWire (not a plain Error) carrying the processor-provided reason, retry, metadata, and processorId, to abort the workflow step.
Source
Thrown at packages/core/src/workflows/entry-executors/run-agent-entry.ts:130
// throws inside the base output's try/catch (see output.ts:970-973,978-981)
// and it fires BEFORE handleFinish, so racing here would poison
// streamPromise. Only the rejection channel below is wired up so genuine
// stream errors still propagate.
void modelOutput.text.then(
() => {},
(err: unknown) => streamPromise.reject(err),
);
stream = modelOutput.fullStream as ReadableStream<ChunkType>;
}
const tripwireChunk =
streamFormat === 'legacy'
? await bridgeLegacyWatchEvents({ stream, pubsub, runId, toolData })
: await consumeStreamForTripwire(stream, writer);
// If a tripwire was detected, throw TripWire to abort the workflow step
if (tripwireChunk) {
throw new TripWire(
tripwireChunk.payload?.reason || 'Agent tripwire triggered',
{
retry: tripwireChunk.payload?.retry,
metadata: tripwireChunk.payload?.metadata,
},
tripwireChunk.payload?.processorId,
);
}
if (abortSignal.aborted) {
return abort();
}
// Return structured output if available, otherwise default text
if (structuredResult !== null) {
return structuredResult;
}
return {View on GitHub (pinned to 75dd419e61)
Solutions
- Inspect TripWire.reason and processorId to identify which processor tripped and why.
- Adjust or remove the offending processor configuration on the agent if the trip is a false positive.
- Handle TripWire in your workflow error handling (it is distinct from Error) — catch it and branch or retry as appropriate.
- Use the TripWire retry/metadata payload to decide whether to retry the step.
Example fix
// before
await wf.run({ input }); // unhandled TripWire aborts run
// after
try { await wf.run({ input }); }
catch (e) { if (e instanceof TripWire) { console.warn('Tripped by', e.processorId, e.reason); } else throw e; } Defensive patterns
Strategy: try-catch
Validate before calling
const processors = agent?.inputProcessors ?? [];
if (processors.some(p => p?.id === 'strict-moderation')) {
// pre-screen input before running the workflow step
if (await violatesPolicy(input)) throw new PolicyError('Input would trip moderation processor');
} Type guard
import { TripWire } from '@mastra/core/workflows';
function isTripWire(e: unknown): e is TripWire {
return e instanceof TripWire;
} Try / catch
try { await runWorkflow(input); }
catch (e) {
if (e instanceof TripWire) {
logger.warn({ reason: e.reason, processorId: e.processorId, metadata: e.metadata }, 'workflow tripped');
return { status: 'blocked', reason: e.reason };
}
throw e;
} Prevention
- Always catch TripWire separately from Error in workflow runners.
- Log TripWire.processorId to identify offending processors quickly.
- Test agent processors against edge-case inputs before production.
- Surface tripwire reasons to end users instead of generic 500s.
When it happens
Trigger: An agent stream inside a workflow step emits a tripwire chunk — typically an input or output processor (e.g. moderation, guardrails) flagged the prompt or response — with streamFormat legacy or vnext handled via consumeStreamForTripwire.
Common situations: Content moderation / guardrail processors rejecting user input; custom output processors aborting on policy violations; users testing with prompts that trip configured safety processors.
Related errors
- Tripwire triggered in workflow ${workflow.id}
- Stream part blocked by ${processor.id}
- Aborted by processor
- TokenLimiterProcessor: System messages alone exceed token li
- TokenLimiterProcessor: No messages fit within the remaining
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/396f2dcf5b0fcfab.
Report an issue: GitHub.