Golem stateless agent effect

From golemcloud/golem · View interactive version

Golem stateless agent effect is an AI agent skill from the GitHub repository golemcloud/golem. Creates ephemeral, stateless Effect Golem agents with fresh handlers for every invocation. Use for pure request handlers, independent transformations, or agents that must not share state between calls.

How to use this skill

Skill file

Creating Ephemeral Agents with Effect

An ephemeral agent gets a fresh implementation for every invocation. Its agent id fields

still describe its logical identity, but values captured by one invocation's handlers are discarded

when that invocation completes. The oplog remains available for inspection, but Golem does not

replay it to recover an ephemeral agent.

Use ephemeral agents for independent request handling, transformations, validation, adapters, and

other work where one call must not depend on an earlier call. Use a durable agent instead for

counters, carts, workflows, long-running orchestration, or external operations that require durable

recovery.

Define and Implement the Agent

Set mode: "ephemeral" in defineAgent(...). Declare constructor and method contracts with Effect

Schema, return Effect values from every handler, and omit snapshot for a stateless agent:

import { Effect, Schema } from "effect";
import { defineAgent, method } from "@golemcloud/effect-golem";

export const TextProcessorAgent = defineAgent({
  name: "TextProcessorAgent",
  mode: "ephemeral",
  id: {
    processorName: Schema.String,
  },
  methods: {
    toUpper: method({
      input: { input: Schema.String },
      success: Schema.String,
    }),
    toLower: method({
      input: { input: Schema.String },
      success: Schema.String,
    }),
  },
}).implement({
  init: () => Effect.void,
  methods: () => ({
    toUpper: ({ input }) => Effect.succeed(input.toUpperCase()),
    toLower: ({ input }) => Effect.succeed(input.toLowerCase()),
  }),
});

The .implement({ init, methods }) call registers the agent eagerly when the module is evaluated. Import the

implementation module from the component entry point so registration occurs:

// src/main.ts
import "./text-processor-agent.js";

Generated Effect projects use ESM and NodeNext module resolution, so local imports use the emitted

.js suffix.

Fresh Invocation Semantics

For every invocation, Golem:

  1. Starts a fresh ephemeral agent instance.
  2. Runs init and then methods to obtain that instance's handlers.
  3. Runs the requested handler.
  4. Discards the instance and its captured in-memory values.

Do not add Snapshot.define(...) or create mutable state merely to

represent a stateless handler. Omitting snapshot disables snapshotting. If calls must observe or

update shared state, the agent is not stateless; use a durable agent and the normal snapshot-backed

state pattern instead.

Effect and CLI Conventions

Promise-returning handlers from the non-Effect TypeScript SDK.

snake_case names.

keys and method arguments use TypeScript value syntax.

TextProcessorAgent("processor-1"); each invocation runs on a new one-shot instance.

ephemeral mode changes instance lifetime and recovery, not the available capabilities.

src/main.ts side-effect import is the registration path.

Choosing Ephemeral Mode

Choose mode: "ephemeral" when every invocation is independent and losing its in-memory values at

the end of the call is intentional. Keep the default durable mode when:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.