Skip to content

Runtime Overview

A runtime is what actually executes your agents. Helix Agents provides three runtimes, each suited to different deployment scenarios. Your agent definitions work identically across all runtimes - only the execution environment changes.

What Is a Runtime?

The runtime orchestrates the agent execution loop:

  1. Initialize agent state
  2. Call the LLM with messages and tools
  3. Execute any tool calls
  4. Handle sub-agents
  5. Persist state
  6. Stream events
  7. Repeat until completion

Different runtimes handle these steps differently based on their execution model.

Available Runtimes

RuntimePackageBest For
JavaScript@helix-agents/runtime-jsDevelopment, testing, simple deployments
Temporal@helix-agents/runtime-temporalProduction, long-running agents, durability
Cloudflare@helix-agents/runtime-cloudflareEdge deployment, serverless, global scale

Comparison

Execution Model

FeatureJS RuntimeTemporal RuntimeCloudflare Runtime
DurabilityNone (in-memory)Full (workflow persistence)Limited (workflow steps)
Crash RecoveryNoYesYes (step-level)
Timeout HandlingManualPer-activity timeoutsPer-step timeouts
Retry LogicManualAutomatic with configAutomatic
Multi-ProcessNoYes (workers)Yes (edge nodes)

State & Streaming

FeatureJS RuntimeTemporal RuntimeCloudflare Runtime
State StoreMemory/RedisMemory/RedisD1 Database
Stream ManagerMemory/RedisMemory/RedisDurable Objects
Sub-Agent ExecutionIn-processChild workflowsNested workflow calls

Operational

FeatureJS RuntimeTemporal RuntimeCloudflare Runtime
InfrastructureNoneTemporal ServerCloudflare Account
ComplexityLowMedium-HighMedium
CostHosting onlyTemporal Cloud or self-hostCloudflare pricing
ScalingVerticalHorizontal (workers)Automatic (edge)

Choosing a Runtime

Use JavaScript Runtime When:

  • Development and testing - Fast iteration without infrastructure
  • Simple deployments - Single-process, short-lived agents
  • Prototyping - Explore ideas before production setup
  • Serverless functions - Lambda/Cloud Functions where execution is short
typescript
import { JSAgentExecutor, InMemoryStateStore, InMemoryStreamManager } from '@helix-agents/sdk';

const executor = new JSAgentExecutor(
  new InMemoryStateStore(),
  new InMemoryStreamManager(),
  llmAdapter
);

Use Temporal Runtime When:

  • Production workloads - Need reliability and observability
  • Long-running agents - Execution may take hours or days
  • Crash recovery - Agent must survive process restarts
  • Complex orchestration - Multi-agent systems with dependencies
typescript
import { TemporalAgentExecutor } from '@helix-agents/runtime-temporal';

const executor = new TemporalAgentExecutor({
  client: temporalClient,
  stateStore: redisStateStore,
  streamManager: redisStreamManager,
  workflowName: 'agent_workflow',
  taskQueue: 'agents',
});

Use Cloudflare Runtime When:

  • Global edge deployment - Low latency worldwide
  • Serverless architecture - No servers to manage
  • Cloudflare ecosystem - Already using Workers, D1, DO
  • Cost optimization - Pay per request, automatic scaling
typescript
import { CloudflareAgentExecutor } from '@helix-agents/runtime-cloudflare';

const executor = new CloudflareAgentExecutor({
  workflowBinding: env.AGENT_WORKFLOW,
  stateStore: d1StateStore,
  streamManager: doStreamManager,
});

Common API

All runtimes implement the AgentExecutor interface:

typescript
interface AgentExecutor {
  // Execute an agent with input
  execute<TState, TOutput>(
    agent: AgentConfig<...>,
    input: string | { message: string; state?: Partial<TState> },
    options?: ExecuteOptions
  ): Promise<AgentExecutionHandle<TOutput>>;

  // Reconnect to existing run
  getHandle<TState, TOutput>(
    agent: AgentConfig<...>,
    runId: string
  ): Promise<AgentExecutionHandle<TOutput> | null>;
}

The returned handle provides:

typescript
interface AgentExecutionHandle<TOutput> {
  runId: string;

  // Stream real-time events
  stream(): Promise<AsyncIterable<StreamChunk> | null>;

  // Wait for final result
  result(): Promise<AgentResult<TOutput>>;

  // Cancel execution
  abort(reason?: string): Promise<void>;

  // Get current state
  getState(): Promise<AgentState<unknown, TOutput>>;

  // Check if resumable
  canResume(): Promise<CanResumeResult>;

  // Resume execution
  resume(options?: ResumeOptions): Promise<AgentExecutionHandle<TOutput>>;
}

Swapping Runtimes

Because all runtimes share the same interface, swapping is straightforward:

typescript
// Development
const executor =
  process.env.NODE_ENV === 'production'
    ? new TemporalAgentExecutor({
        /* production config */
      })
    : new JSAgentExecutor(memoryStore, memoryStream, llmAdapter);

// Same usage regardless of runtime
const handle = await executor.execute(myAgent, 'Research AI agents');
const result = await handle.result();

This is the core philosophy of Helix Agents: define once, execute anywhere.

Next Steps

Released under the MIT License.