Agent Runtime & Orchestration (v0.2.0)¶
The Agent Runtime is the central nervous system of the Isolated Agents SDK. Introduced in v0.2.0, it transitions the SDK from a library for execution into a professional service for agent orchestration.
๐๏ธ Architecture Overview¶
The v0.2.0 architecture consists of three core background services:
- Agent Runtime: Manages global session state, persistent working directories, and lifecycle events.
- Spawn Daemon: A Unix Domain Socket IPC server that facilitates secure container-to-host recursion.
- Agent Scheduler: A background task engine for recurring intervals and delayed execution.
๐ The Agent Runtime¶
The AgentRuntime class provides a unified high-level interface.
Starting the Runtime¶
from isolated_agents_sdk import AgentRuntime
runtime = AgentRuntime(working_dir="./prod_workspace")
# Start background services (Spawn Daemon, etc.)
await runtime.start()
# Status check
print(runtime.get_status())
Running Agents via Runtime¶
Running an agent through the runtime ensures it is tracked and can use the Spawn Daemon for recursion.
from isolated_agents_sdk import Policy
policy = Policy(allow_sub_agents=True)
# Run an agent
result = await runtime.run_agent(
agent=my_agent_func,
policy=policy
)
๐งต Sub-Agent Nesting (Spawn Daemon)¶
Agents running inside isolation can now securely spawn their own sub-agents.
Internal Agent Logic¶
Inside your agent function, use the spawn_sub_agent utility:
from isolated_agents_sdk.sub_agent_client import spawn_sub_agent
def parent_agent():
print("Spawning child...")
result = spawn_sub_agent(
agent=child_agent_logic,
policy=Policy(memory_mb=128)
)
return f"Child finished with: {result.exit_code}"
โฐ Background Scheduling¶
The AgentScheduler enables cron-like behavior for agent automation.
from isolated_agents_sdk import AgentScheduler
scheduler = AgentScheduler()
# Every 5 minutes
await scheduler.schedule_agent_interval(
interval_seconds=300,
agent=cleanup_script
)
# 10 second delay
await scheduler.schedule_agent_in(
delay_seconds=10,
agent=one_off_task
)
๐ Structured JSON Logging¶
For production environments, enable machine-readable logs.
from isolated_agents_sdk import setup_logging
# Enable structured JSON output
setup_logging(structured=True, level="INFO")
Example Output: