monitoring agent - kongusen/loom-agent GitHub Wiki
Use this pattern when the agent should respond to changing system state, not only static prompts.
- service monitoring assistants
- codebase watchers
- runtime health agents
- agents that combine observation with guarded actions
from loom import Agent, Model, Runtime, RuntimeSignal, SessionConfig
agent = Agent(
model=Model.anthropic("claude-sonnet-4"),
instructions="Monitor the system and recommend safe next steps.",
runtime=Runtime.long_running(criteria=["recommendations are safe and actionable"]),
)
session = agent.session(SessionConfig(id="ops"))
await session.receive(
RuntimeSignal.create(
"CPU usage exceeded 90%",
source="heartbeat",
type="alert",
urgency="high",
payload={"host": "api-1"},
)
)
result = await session.run("Assess pending runtime signals")Monitoring enters the runtime as signal input.
That keeps the kernel simple:
- heartbeat adapters emit
RuntimeSignal - gateway and cron adapters emit the same contract
-
AttentionPolicydecides whether a signal should cause execution - tools and remediation still go through
CapabilityandGovernancePolicy
- combine with
SignalAdapterfor real heartbeat, webhook, or gateway event shapes - combine with
Capability.shell(require_approval=True)when remediation is allowed - use
Runtime.supervised(...)when human review is required