> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Lifecycle Command Guard Policy • AI Agent SDK

> LifecycleCommandGuardPolicy: Config-driven, command-anchored guard against gateway self-lifecycle hits.

# LifecycleCommandGuardPolicy

> Defined in the [**protocols**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/protocols.md) module.

AI Agent

Config-driven, command-anchored guard against gateway self-lifecycle hits.

The default referenced by `gateway.lifecycle_guard` blocks in
`gateway.yaml` and the `BotOS(..., lifecycle_policy=...)` Python
surface. It is intentionally minimal and dependency-free so the decision
lives in core and is provable in isolation; the wrapper owns the consult
points (shell-tool executor, scheduler job registration) and the audit log.

Matching is *structural*, not prose-based, to avoid false positives on
ordinary English (e.g. "please stop the gateway from spamming"):

* `praisonai gateway stop|restart|reload` — the CLI self-control verbs,
  matched only when `praisonai` and `gateway` appear as adjacent
  command tokens followed by a lifecycle verb.
* `pkill` / `kill` / `killall` naming the gateway (a configured
  `process_names` token — `praisonai` by default — appearing as a whole
  component in the argument list or a `-f` pattern).
* `systemctl` / `launchctl` / `sc` `stop` / `restart` / `kill`
  on a unit whose name mentions the gateway (same whole-component match).

Matching is *whole-component*, not bare substring: unrelated services whose
name merely contains a token (`api-gateway`, `kong-gateway`) are not
tripped, while the real `praisonai-gateway` unit still matches.

The scan is applied to every `;`/`&&`/`||`/pipe-separated segment of
the command *and* to any additional script text supplied, so a command that
shells out to a wrapper script cannot smuggle the intent past the guard.

`default_allow` is a fail posture: on any internal parsing error the guard
keeps today's behaviour (allow) unless `default_allow=False` is set for a
strict, fail-closed deployment. `enabled=False` disables the guard
entirely (an operator who legitimately wants an agent to manage the
process).

Example::

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
LifecycleCommandGuardPolicy()                    # on by default
LifecycleCommandGuardPolicy(enabled=False)       # opt out
LifecycleCommandGuardPolicy(process_names=["praisonai", "mybot"])
```

## Constructor

**enabled** `bool` (default: True)

No description available.

**process\_names** `Optional`

No description available.

**default\_allow** `bool` (default: True)

No description available.

## Methods

> [card] [evaluate()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/LifecycleCommandGuardPolicy-evaluate.md)
>
> Return a :class:`LifecycleCommandDecision` for `command`.

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L6960)
>
> `praisonaiagents/gateway/protocols.py` at line 6960


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.