Golem – new OSS durable runtime for agents

jdegoes1 pts0 comments

Golem — The durable agent runtime

1.6k Get started →

Agents that never fail.Policies that never bend.<br>The durable agent runtime that automatically persists state , executes every tool call exactly once , and enforces every policy . Reliability and trust by construction.

Get started → View on GitHub

TypeScript Rust Scala MoonBit<br>orders-agent.ts<br>const Orders = agentDefinition('orders')<br>.id({ customerId: z.string() })<br>.config(z.object({ systemPrompt: z.string() }))<br>.method('handle', m => m<br>.input(z.object({ request: z.string(), orderId: z.string() }))<br>.returns(z.object({ resolved: z.boolean() })))

export default Orders.implement({<br>init: () => ({ history: [] as Message[] }),<br>methods: {<br>async handle({ request, orderId }) {<br>// No DB writes — this push survives crashes, deploys, host migrations<br>this.history.push({ role: 'user', content: request })

// LLM sees full conversation; system prompt comes from typed config<br>const outcome = await llm.run({<br>prompt: this.config.systemPrompt, history: this.history,<br>tools: [cancelOrder, changeAddress], context: { orderId },<br>})<br>this.history.push({ role: 'assistant', content: outcome.message })

// Refunds aren't in the LLM's toolset — agent code gates them via HITL<br>if (outcome.needsRefund) {<br>// This await can sit for days at zero cost — no queue, no cron, no state table<br>const { approved } = await webhooks.awaitApproval(outcome)<br>if (approved) {<br>// Crash, retry, restart — still one charge. No silent double-charges.<br>const result = await refundOrder({ orderId, amount: outcome.refundAmount })<br>this.history.push({ role: 'tool', content: JSON.stringify(result) })<br>return { resolved: true }<br>},<br>},<br>})<br>#[derive(ConfigSchema)]<br>pub struct OrdersConfig { pub system_prompt: String }

#[agent_definition]<br>pub trait Orders {<br>async fn handle(&mut self, request: String, order_id: String) -> bool;

struct OrdersImpl { config: ConfigOrdersConfig>, history: VecMessage> }

#[agent_implementation]<br>impl Orders for OrdersImpl {<br>async fn handle(&mut self, request: String, order_id: String) -> bool {<br>// No DB writes — this push survives crashes, deploys, host migrations<br>self.history.push(Message::user(request));

// LLM sees full conversation; system prompt comes from typed config<br>let outcome = llm::run(<br>&self.config.get().system_prompt, &self.history,<br>vec![cancel_order(), change_address()], order_id.clone(),<br>).await;<br>self.history.push(Message::assistant(outcome.message.clone()));

// Refunds aren't in the LLM's toolset — agent code gates them via HITL<br>if outcome.needs_refund {<br>// This await can sit for days at zero cost — no queue, no cron, no state table<br>let approval = create_webhook().await.json::Approval>();<br>if approval.approved {<br>// Crash, retry, restart — still one charge. No silent double-charges.<br>let result = refund_order(order_id, outcome.refund_amount).await;<br>self.history.push(Message::tool(result.to_string()));<br>true<br>final case class OrdersConfig(systemPrompt: String)

@agentDefinition()<br>trait Orders extends BaseAgent with AgentConfig[OrdersConfig]:<br>def handle(request: String, orderId: String): Future[Boolean]

@agentImplementation()<br>final class OrdersImpl(customerId: String, config: Config[OrdersConfig]) extends Orders:<br>private var history: Vector[Message] = Vector.empty

override def handle(request: String, orderId: String): Future[Boolean] = Future:<br>// No DB writes — this push survives crashes, deploys, host migrations<br>history = history :+ Message("user", request)

// LLM sees full conversation; system prompt comes from typed config<br>val outcome = llm.run(<br>prompt = config.value.systemPrompt, history = history,<br>tools = Seq(cancelOrder, changeAddress), context = Map("orderId" -> orderId)).await<br>history = history :+ Message("assistant", outcome.message)

// Refunds aren't in the LLM's toolset — agent code gates them via HITL<br>if outcome.needsRefund then<br>// This await can sit for days at zero cost — no queue, no cron, no state table<br>val approval = HostApi.createWebhook().await.json[Approval]()<br>if approval.approved then<br>// Crash, retry, restart — still one charge. No silent double-charges.<br>val result = refundOrder(orderId, outcome.refundAmount).await<br>history = history :+ Message("tool", result.toString)<br>true<br>#derive.config<br>pub(all) struct OrdersConfig { system_prompt : String }

#derive.agent<br>struct Orders {<br>config : @config.Config[OrdersConfig]<br>mut history : Array[Message]

pub fn Orders::handle(self : Self, request : String, order_id : String) -> Bool {<br>// No DB writes — this push survives crashes, deploys, host migrations<br>self.history.push({ role: "user", content: request })

// LLM sees full conversation; system prompt comes from typed config<br>let outcome = @llm.run(<br>prompt = self.config.value().system_prompt, history = self.history,<br>tools = [cancel_order(), change_address()], context = { "order_id": order_id },<br>self.history.push({ role: "assistant", content: outcome.message })

// Refunds aren't in the LLM's toolset — agent code gates them via HITL<br>if outcome.needs_refund {<br>// This await can...

history string config outcome message await

Related Articles