Creating Ephemeral (Stateless) Agents (Scala)
SkillAI & modelsHelps create stateless agents in Scala that start fresh each time they run.
Use Creating Ephemeral (Stateless) Agents (Scala) in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add Creating Ephemeral (Stateless) Agents (Scala) and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the Creating Ephemeral (Stateless) Agents (Scala) skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
About this skill
Creating ephemeral (stateless) agents in a Scala Golem project. Use when the user wants a stateless agent, a fresh instance per invocation, no shared state between calls, or a request-handler style agent.
What this skill tells your AI
The instructions your AI receives, as published by golemcloud/golem in golem-skills/skills/scala/golem-stateless-agent-scala/SKILL.md and read by Ahel’s review.
Overview
An ephemeral agent is a Golem agent that gets a fresh instance for every invocation. Unlike the default durable agents, ephemeral agents:
- No shared state: Each invocation starts from a fresh constructor call — field values set in one call are gone by the next
- No replay: An oplog is still recorded lazily (useful for debugging via
golem agent oplog), but it is never used for replay — no automatic recovery on failure - No persistence: The agent's memory is discarded after each invocation completes
- Same identity model: The agent is still addressed by its constructor parameters, but every call behaves as if the agent was just created
This makes ephemeral agents ideal for pure request handlers, stateless transformers, adapters, and serverless-style functions where each call is independent.
How to Create an Ephemeral Agent
Pass mode = DurabilityMode.Ephemeral to the @agentDefinition annotation:
import golem.runtime.annotations.{agentDefinition, agentImplementation, DurabilityMode}
import golem.BaseAgent
import scala.concurrent.Future
@agentDefinition(mode = DurabilityMode.Ephemeral)
trait RequestHandler extends BaseAgent {
def handle(input: String): Future[String]
}
@agentImplementation()
final class RequestHandlerImpl extends RequestHandler {
override def handle(input: String): Future[String] =
Future.successful(s"processed: $input")
}
What "Fresh Instance Per Invocation" Means
Consider a durable agent vs an ephemeral one:
// DURABLE (default) — state accumulates across calls
@agentDefinition()
trait DurableCounter extends BaseAgent {
class Id(val name: String)
def increment(): Future[Int]
}
@agentImplementation()
final class DurableCounterImpl(name: String) extends DurableCounter {
private var count: Int = 0
override def increment(): Future[Int] = Future.successful {
count += 1
count
}
}
// Call increment() three times → returns 1, 2, 3
// EPHEMERAL — state resets every call
@agentDefinition(mode = DurabilityMode.Ephemeral)
trait EphemeralCounter extends BaseAgent {
class Id(val name: String)
def increment(): Future[Int]
}
@agentImplementation()
final class EphemeralCounterImpl(name: String) extends EphemeralCounter {
private var count: Int = 0
override def increment(): Future[Int] = Future.successful {
count += 1
count
}
}
// Call increment() three times → returns 1, 1, 1
Each invocation of an ephemeral agent:
- Creates a fresh instance via the constructor
- Executes the method
- Discards the instance entirely
Combining with HTTP Endpoints
Ephemeral agents are a natural fit for HTTP request handlers:
import golem.runtime.annotations._
import golem.BaseAgent
import scala.concurrent.Future
@agentDefinition(mode = DurabilityMode.Ephemeral, mount = "/api/convert/{name}")
trait ConverterAgent extends BaseAgent {
class Id(val name: String)
@post("/to-upper")
def toUpper(@body input: String): Future[String]
@post("/to-lower")
def toLower(@body input: String): Future[String]
}
@agentImplementation()
final class ConverterAgentImpl(private val name: String) extends ConverterAgent {
override def toUpper(input: String): Future[String] =
Future.successful(input.toUpperCase)
override def toLower(input: String): Future[String] =
Future.successful(input.toLowerCase)
}
When to Use Ephemeral Agents
| Use Case | Why Ephemeral? |
|---|---|
| Stateless HTTP API (REST adapter, proxy) | No state to persist between requests |
| Data transformation / format conversion | Pure function — input in, output out |
| Validation service | Each validation is independent |
| Webhook receiver that forwards events | No need to remember previous webhooks |
| Stateless computation (math, encoding) | No side effects worth persisting |
When NOT to Use Ephemeral Agents
- Counters, accumulators, shopping carts — need state across calls → use durable (default)
- Workflow orchestrators, sagas — need oplog for recovery → use durable (default)
- Agents calling external APIs where at-least-once semantics matter → use durable (default)
- Any agent where one call's result depends on a previous call → use durable (default)
Key Points
- Ephemeral mode is set at the agent type level — all instances of the type are ephemeral
- Constructor parameters still define identity — you can have multiple ephemeral agents with different parameters
- Ephemeral agents can still call other agents via RPC, make HTTP requests, and use all Golem APIs
- The oplog is still recorded lazily, so you can inspect what an ephemeral agent did via
golem agent oplog— but it is never replayed
Signals
- GitHub stars
- 2k
- Forks
- 210
- Last commit
- Oct 2026
Advanced
- Item type
- skill
- Key
golem-stateless-agent-scala- Source
- github.com/golemcloud/golem
More in AI & models
Skill · anthropics
More in AI & modelstriage
Skill · mattpocock
More in AI & modelswayfinder
Skill · mattpocock
More in AI & modelsalgorithmic-art
Skill · anthropics
More in AI & modelscode-review-and-quality
Skill · addyosmani
More in AI & modelsmarketing-psychology
Skill · coreyhaines31
More in AI & models