Ops Agents¶
OpsAgent¶
OpsAgent ¶
Bases: ABC
Base class for operational agents.
Ops agents are registered with AgenticApp via register_ops_agent() and participate in the application lifecycle. They start when the app starts and stop when the app shuts down.
Subclasses must implement start(), stop(), and check_health().
Example
class MyOpsAgent(OpsAgent): async def start(self) -> None: self._running = True
async def stop(self) -> None:
self._running = False
async def check_health(self) -> OpsHealthStatus:
return OpsHealthStatus(healthy=self._running)
app = AgenticApp() app.register_ops_agent(MyOpsAgent(name="my-agent"))
Source code in src/agenticapi/ops/base.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
__init__ ¶
__init__(
*,
name: str,
autonomy: AutonomyLevel = AutonomyLevel.SUPERVISED,
max_severity: Severity = Severity.MEDIUM,
) -> None
Initialize the ops agent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique name identifying this ops agent. |
required |
autonomy
|
AutonomyLevel
|
The autonomy level for this agent's actions. |
SUPERVISED
|
max_severity
|
Severity
|
Maximum severity level the agent can handle autonomously. |
MEDIUM
|
Source code in src/agenticapi/ops/base.py
start
abstractmethod
async
¶
Start the ops agent.
Called during application startup. Implementations should initialize background tasks, connect to monitoring systems, etc.
stop
abstractmethod
async
¶
Stop the ops agent.
Called during application shutdown. Implementations should clean up resources and cancel background tasks.
check_health
abstractmethod
async
¶
Check the health of this ops agent.
Returns:
| Type | Description |
|---|---|
OpsHealthStatus
|
The current health status. |
can_handle_autonomously ¶
Check if the agent can handle an issue at the given severity autonomously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
severity
|
Severity
|
The severity of the issue. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the agent can act without human approval. |
Source code in src/agenticapi/ops/base.py
OpsHealthStatus¶
OpsHealthStatus ¶
Health status of an ops agent.
Attributes:
| Name | Type | Description |
|---|---|---|
healthy |
Whether the agent is operating normally. |
|
message |
Optional human-readable status message. |
|
details |
Optional additional details. |