golem-wait-for-external-input-rust

Implements durable promise-based suspension of Rust Golem agents until external input arrives.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Building workflows that must pause until an external event occurs—such as human approval, a webhook callback, or a signal from another agent—normally requires complex polling or state management. This Skill shows how to use Golem promises in Rust to durably suspend an agent, consuming no resources, until the promise is completed from outside.

Core Features & Use Cases

  • Promise Creation and Awaiting: Create a promise with create_promise, then block synchronously with blocking_await_promise or asynchronously with await_promise until it completes.
  • JSON Helpers: Use await_promise_json and complete_promise_json from golem_rust::json to exchange structured, serde-serializable data instead of raw bytes.
  • External Completion via REST: Expose the promise's oplog_idx so external systems can complete it through the Golem REST API endpoint /v1/components/{component_id}/workers/{agent_name}/complete.
  • Use Case: Implement a human-in-the-loop approval workflow where an agent creates a promise, suspends, and resumes only after a human approves or rejects via an external UI or HTTP call.

Quick Start

Ask the AI to implement a Golem agent in Rust that creates a promise and waits for external approval before continuing its workflow.

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

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

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

Create a promise with create_promise from the golem_rust crate, pass the PromiseId to an external system, then call blocking_await_promise or await_promise. The Golem runtime durably suspends the agent, consuming no resources, 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 data bytes. The agent must expose the oplog_idx field of its PromiseId so the external caller can target the correct promise.

Can I send structured JSON data through Golem promises?

Yes, the golem_rust::json module provides await_promise_json, blocking_await_promise_json, and complete_promise_json. These serialize and deserialize any serde-compatible type, returning a Result that wraps serde_json errors.

What is the difference between await_promise and blocking_await_promise?

blocking_await_promise is a synchronous function that blocks until the promise completes, while await_promise is the async variant used with .await in async agent methods. Both return the promise payload as a Vec<u8>.

What are common use cases for Golem promises?

Golem promises suit human-in-the-loop approvals, webhook callback handling, inter-agent synchronization where one agent completes another's promise, and suspending execution until IoT sensors, payment gateways, or third-party APIs send a signal.