Skip to main content

Function: runPostApprovalGuardrails()

runPostApprovalGuardrails(toolName, args, guardrailIds, callbacks?): Promise<GuardrailHitlOverrideResult>

Defined in: packages/agentos/src/api/agency.ts:2098

Runs the post-approval checks after an approval handler approves a tool call, an agent run or the final output.

The checks are two fixed pattern checks inside agency(), code-safety and pii-redaction, not the guardrail packs: any other ID passes. They run in the order guardrailIds lists them, each over one text, Tool: <toolName> and then Arguments: with args as JSON, and the first that matches returns passed: false with its ID and reason; the caller then overrides the approval. A check that throws is skipped. The final output is checked as the strategy produced it and, when the approval's modifications.output replaces it, as the replacement the caller receives, after the agency's output guardrails have read it; a replacement does not clear a strategy text a check blocks.

Parameters​

toolName​

string

The approved tool's name, agent:<name> for an agent approval, or return for the final output.

args​

Record<string, unknown>

The tool call's arguments; for an agent, { input } with the strategy's input, plus sent, the text the agent is sent, when the approval's instructions were appended to it, and parts, the task and the other agents' output the strategy built the input from, each on its own, under sequential (after its first agent), graph, review-loop and debate and for the panel's chair; for the final output, { output } with the strategy's text, plus returned, the approval's replacement, when it carries one.

guardrailIds​

string[]

Ordered list of check IDs to run.

callbacks?​

AgencyCallbacks

Optional event callback map; each check's result goes to guardrailResult.

Returns​

Promise<GuardrailHitlOverrideResult>

A result indicating whether every check passed.