TeleonTeleon AITeleon AI

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.

What this tutorial covers

  • Creating an AgentRuntime with RuntimeConfig
  • Registering and starting an agent
  • Scaling to a specific instance count
  • Fetching status
  • Adding a custom health check

Prerequisites

pip install teleon

Helix runtime APIs are async. Run these examples inside an async function (for example, using asyncio.run(...)).

1) Create a runtime

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

2) Register and start an agent

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")

3) Scale the agent

await runtime.scale_agent("my-agent", instances=5)

4) Get status and stop

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

5) Add a health check

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,
)

6) Shut down

await runtime.stop_agent("my-agent")
await runtime.stop()

On this page