Manage an Agent Runtime with Helix
Register, start, scale, and check health using AgentRuntime
This tutorial follows the Helix runtime documentation and shows the basic operational flow.
- Creating an
AgentRuntime with RuntimeConfig
- Registering and starting an agent
- Scaling to a specific instance count
- Fetching status
- Adding a custom health check
Helix runtime APIs are async. Run these examples inside an async function (for example, using asyncio.run(...)).
from teleon.helix import AgentRuntime, RuntimeConfig
config = RuntimeConfig(
environment="production",
hot_reload=False,
max_workers=20,
)
runtime = AgentRuntime(config)
Health statuses:
from teleon.helix import HealthStatus
HealthStatus.HEALTHY
HealthStatus.UNHEALTHY
HealthStatus.DEGRADED
HealthStatus.UNKNOWN
from teleon.helix import ResourceConfig
await runtime.register_agent(
agent_id="my-agent",
agent_callable=my_agent_function,
resources=ResourceConfig(min_instances=2, max_instances=10),
)
await runtime.start()
await runtime.start_agent("my-agent")
await runtime.scale_agent("my-agent", instances=5)
status = await runtime.get_agent_status("my-agent")
await runtime.stop_agent("my-agent")
get_agent_status() returns a dictionary that includes keys like:
status
instances
resources
processes
health
from teleon.helix import HealthCheck, CheckType
async def custom_check():
return True
health_check = HealthCheck(
name="database-check",
check_type=CheckType.CUSTOM,
check_fn=custom_check,
interval=30,
timeout=10,
failure_threshold=3,
success_threshold=1,
initial_delay=5,
)
Attach it when registering your agent:
await runtime.register_agent(
agent_id="my-agent",
agent_callable=my_agent_function,
resources=ResourceConfig(min_instances=2, max_instances=10),
health_check=health_check,
)
await runtime.stop_agent("my-agent")
await runtime.stop()