Interface ICrossAgentGuardrailService

Cross-agent guardrail service for multi-agent supervision.

Extends IGuardrailService to enable observation and intervention in other agents' output streams. Use this for:

  • Supervisor patterns: A supervisor agent monitors worker agents
  • Quality gates: Enforce quality standards across an agency
  • Policy enforcement: Apply organization-wide rules to all agents
  • Safety monitoring: Detect and prevent harmful outputs from any agent

Example: Quality gate guardrail

class QualityGateGuardrail implements ICrossAgentGuardrailService {
// Observe all agents in the agency
observeAgentIds = [];
canInterruptOthers = true;

async evaluateCrossAgentOutput({ sourceAgentId, chunk, context }) {
if (chunk.type === 'FINAL_RESPONSE') {
const quality = await assessQuality(chunk.finalResponseText);
if (quality.score < 0.5) {
return {
action: GuardrailAction.BLOCK,
reason: 'Response did not meet quality standards',
metadata: { qualityScore: quality.score, agent: sourceAgentId }
};
}
}
return null;
}
}

Example: Selective agent monitoring

class SensitiveDataGuardrail implements ICrossAgentGuardrailService {
// Only observe agents handling sensitive data
observeAgentIds = ['data-analyst', 'report-generator'];
canInterruptOthers = true;
config = { evaluateStreamingChunks: true };

async evaluateCrossAgentOutput({ chunk }) {
if (chunk.textDelta && containsPII(chunk.textDelta)) {
return {
action: GuardrailAction.SANITIZE,
modifiedText: redactPII(chunk.textDelta)
};
}
return null;
}
}
interface ICrossAgentGuardrailService {
    observeAgentIds?: string[];
    canInterruptOthers?: boolean;
    evaluateCrossAgentOutput?(payload): Promise<null | GuardrailEvaluationResult>;
    config?: GuardrailConfig;
    evaluateInput?(payload): Promise<null | GuardrailEvaluationResult>;
    evaluateOutput?(payload): Promise<null | GuardrailEvaluationResult>;
}

Hierarchy (view full)

Methods

Properties

observeAgentIds?: string[]

Agent IDs this guardrail observes.

  • Empty array [] or undefined: Observe all agents in the agency
  • Specific IDs: Only observe listed agents

Example

// Observe specific workers
observeAgentIds = ['worker-1', 'worker-2'];

// Observe all agents
observeAgentIds = [];
canInterruptOthers?: boolean

Whether this guardrail can interrupt other agents' streams.

When true:

When false (default):

  • Guardrail can only observe and log (FLAG action)
  • BLOCK/SANITIZE actions are downgraded to FLAG

Default

false

Configuration for evaluation behavior. Controls streaming vs final-only evaluation and rate limiting.