golem-wait-for-external-input-scala

Implements durable promise-based suspension for Scala Golem agents awaiting external input.

1.5k|212|Updated Nov 24, 2023
One-click install
npx skills add https://github.com/golemcloud/golem --skill golem-wait-for-external-input-scala
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golem-wait-for-external-input-scala
Source: https://github.com/golemcloud/golem/tree/main/golem-skills/skills/scala/golem-wait-for-external-input-scala
Command: npx skills add https://github.com/golemcloud/golem --skill golem-wait-for-external-input-scala

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Long-running agents often need to pause until an external event occurs—a human approval, a webhook callback, or a signal from another agent. Polling wastes resources and naive blocking loses state on failure. This Skill shows how to use Golem promises in Scala to durably suspend an agent, consuming no resources, until external data arrives.

Core Features & Use Cases

  • Promise Lifecycle API: Create promises with HostApi.createPromise, await them with blocking or Future-based calls, and complete them from other agents or external systems.
  • Typed JSON Variants: Use awaitPromiseBlockingJson and completePromiseJson with zio.blocks.schema.Schema to exchange structured data instead of raw bytes.
  • REST Completion Endpoint: Expose the promise's oplogIdx so external systems can complete it via the Golem REST API.
  • Use Case: Build a human-in-the-loop approval workflow where an agent creates a promise, suspends until a reviewer approves or rejects via an HTTP call, then resumes with the decision.

Quick Start

Ask the AI to implement a Scala Golem agent that creates a promise, waits for an external approval decision, and resumes the workflow with the result.

Frequently Asked Questions about golem-wait-for-external-input-scala

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I wait for external input in a Golem Scala agent?

Create a promise with HostApi.createPromise, pass the promise ID to the external system, then call HostApi.awaitPromiseBlocking with the promise ID. The Golem runtime durably suspends the agent until the promise is completed.

How do I complete a Golem promise from an external system?

Send a POST request to /v1/components/{component_id}/workers/{agent_name}/complete with a JSON body containing the oplogIdx and the data as a byte array. The agent must expose the promise's oplogIdx for this to work.

Can Golem promises carry structured JSON data in Scala?

Yes, use awaitPromiseBlockingJson and completePromiseJson with an implicit zio.blocks.schema.Schema for your type. These variants serialize and deserialize case classes automatically instead of handling raw byte arrays.

What is the difference between awaitPromise and awaitPromiseBlocking?

awaitPromiseBlocking suspends the agent synchronously and returns the raw bytes directly, while awaitPromise returns a Future[Array[Byte]] for asynchronous composition. Both durably suspend the agent until the promise completes.

Does a suspended Golem agent consume resources while waiting?

No, the Golem runtime durably suspends the agent while it awaits a promise, so it consumes no compute resources. The agent resumes automatically once the promise is completed by an external caller.