Lifecycle Command Guard Policy • AI Agent SDK
LifecycleCommandGuardPolicy: Config-driven, command-anchored guard against gateway self-lifecycle hits.
LifecycleCommandGuardPolicy
Defined in the protocols 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 `
praisonaiandgateway` appear as adjacent - command tokens followed by a lifecycle verb.
- `
pkill/kill/killall` naming the gateway (a configured - `
process_namestoken —praisonai` by default — appearing as a whole - component in the argument list or a `
-f` pattern). - `
systemctl/launchctl/scstop/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::
LifecycleCommandGuardPolicy() # on by default
LifecycleCommandGuardPolicy(enabled=False) # opt out
LifecycleCommandGuardPolicy(process_names=["praisonai", "mybot"])Constructor
boolNo description available.
OptionalNo description available.
boolNo description available.
Methods
Source
View on GitHubpraisonaiagents/gateway/protocols.py at line 6960