Skip to Content
How-To GuidesRustConfiguring Agent Durability (Rust)

Configuring Agent Durability (Rust)

Durable Agents (Default)

By default, all Golem agents are durable:

  • State persists across invocations, failures, and restarts
  • Every side effect is recorded in an oplog (operation log)
  • On failure, the agent is transparently recovered by replaying the oplog
  • No special code needed — durability is automatic

A standard durable agent:

use golem_rust::{agent_definition, agent_implementation}; #[agent_definition] pub trait CounterAgent { fn new(name: String) -> Self; fn increment(&mut self) -> u32; fn get_count(&self) -> u32; } struct CounterAgentImpl { name: String, count: u32, } #[agent_implementation] impl CounterAgent for CounterAgentImpl { fn new(name: String) -> Self { Self { name, count: 0 } } fn increment(&mut self) -> u32 { self.count += 1; self.count } fn get_count(&self) -> u32 { self.count } }

Ephemeral Agents

Use ephemeral mode for stateless, per-invocation agents where persistence is not needed:

  • State is discarded after each invocation completes
  • No oplog is maintained — lower overhead
  • Useful for pure functions, request handlers, or adapters
#[agent_definition(ephemeral)] pub trait StatelessHandler { fn new() -> Self; fn handle(&self, input: String) -> String; }

When to Choose Which

Use CaseMode
Counter, shopping cart, workflow orchestratorDurable (default)
Stateless request processor, transformerEphemeral
Long-running saga or multi-step pipelineDurable (default)
Pure computation, no side effects worth persistingEphemeral
Agent that calls external APIs with at-least-once semanticsDurable (default)

When in doubt, use the default (durable). Ephemeral mode is an optimization for agents that genuinely don’t need persistence.

Last updated on