Skip to main content
Four small switches that make a PraisonAI agent safer, more deterministic, and easier to interrupt in production. The user starts a run; core controls enforce safety policies during execution.

Quick Start

1

PII Redaction

2

Deterministic Seed & Cancellation

3

Tool Validation


How It Works


Configuration Options


Deterministic seed

Per-call determinism for reproducible outputs.

Cooperative cancellation

Thread-safe cancellation without hard kills.
Fixed in PR #2751 (release after 2026-07-07): earlier releases only checked cancel_token on the OpenAI completion path in chat_mixin. The litellm-backed tool loop in llm/llm.py (used for Anthropic, Gemini, Groq, local models, and any non-OpenAI provider) took no cancel token and performed no checkpoint, so /stop and InterruptController.request() were silently no-ops on those providers. Upgrade to get uniform cancellation across every provider.
Tightened in PR #2997 (release after 2026-07-14): every tool-loop iteration now checks cancel_token.is_set() twice — at the top of the iteration and again immediately before dispatching tool calls — in both LiteLLM (llm/llm.py) and OpenAI-native (llm/openai_client.py) paths, sync and async. This closes a window where a /stop arriving between the model returning tool calls and the tools starting could still execute one round of tools before honouring the cancel.
Fixed in PR #4301 (release after 2026-08-24): the between-iteration cancel checks documented above were previously never armed on the default OpenAI-native sync path. chat_mixin._chat_completion did not accept cancel_token, so the token was dropped between the agent and OpenAIClient.chat_completion_with_tools. Result: /stop on a plain Agent(...) or Agent(llm="gpt-4o-mini") reported ”✅ Current task cancelled” while every remaining tool call kept executing and chat() returned its normal final answer.PR #4301 threads cancel_token through the four sync hops (_chat_completion_chat_completion_with_retry_execute_unified_chat_completion_unified_dispatcher.chat_completion), so a /stop on the default path now halts between tool iterations exactly as documented. Any model string containing / (LiteLLM path) was already working via PR #2751.
Async default-path still needs threading. PR #4301 covers only the sync path. The async twin _achat_impl has the same shape and the same dropped-token defect — await agent.achat(..., cancel_token=tok) on the default OpenAI-native path will still run its tool loop to completion. Use the sync chat(...) entry point, or route through a provider/model string (LiteLLM path, already fixed by PR #2751) if you need cancellation from achat() today. Tracking follow-up in PR #4301 discussion.
Extended in PR #4248: sync Agent.chat() with a managed backend now honours the cancel token before the backend call, matching achat().

Tool argument validation

Validate tool arguments before execution.
ValidationResult fields:

PII redaction

Scrub sensitive data from LLM requests.
1

Enable once at startup

2

Use agents normally

Every BEFORE_LLM event now passes messages through the scrubber.
3

Disable in tests if needed

Since PraisonAI PR #3908, enable_pii_redaction() — and any other BEFORE_LLM / AFTER_LLM hook — now fires on both agent.chat() and agent.achat(). Earlier releases fired the hook on sync chat() only, so async workflows silently sent unscrubbed prompts to the provider. If your production path went async, upgrade before relying on the redactor.
What gets scrubbed:
  • Key=value pairs: api_key=sk-…, password: hunter2, token=…[REDACTED]
  • Naked tokens: OpenAI-style sk-ABCDEF… keys → [REDACTED]
  • Identifiers: US SSNs 123-45-6789[REDACTED-SSN], credit cards → [REDACTED-CC], emails → [REDACTED-EMAIL]

Which one do I use?


Common Patterns

Reproducible eval

Cancel from Ctrl+C handler

Disable redaction in tests


Best Practices

Some providers ignore seed or treat it as best-effort. Don’t rely on it for production routing decisions.
InterruptController.request(...) is thread-safe. Trip it from a signal handler, an HTTP cancel endpoint, or a parent supervisor.
Validators run on every tool invocation. Avoid network calls or heavy work — return fast ValidationResult objects.
enable_pii_redaction() only scrubs messages going to the LLM. Your local chat history still has the raw prompt — keep it secure or scrub it separately.

Approval

Human-in-the-loop approvals for sensitive operations

Guardrails

Input and output validation with custom rules

Security Environment Variables

Secure handling of API keys and secrets

Hooks

Event system for BEFORE_LLM and BEFORE_TOOL hooks

BEFORE_LLM on async

BEFORE_LLM / AFTER_LLM fire on both chat() and achat()