golem-parallel-workers-moonbit

Implements fan-out and fan-in parallel execution across Golem agents in MoonBit.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Golem agents process invocations sequentially, so a single agent cannot run work in parallel. This Skill shows how to distribute concurrent work across multiple agent instances in a MoonBit Golem project and collect the results.

Core Features & Use Cases

  • Child Agent Fan-Out: Spawn child agents with AgentClient::scoped, dispatch work via fire-and-forget triggers, and gather results through Golem promises.
  • Chunked Fan-Out: Batch child agents to limit concurrency when processing large item sets.
  • Agent Forking: Use @api.fork() to clone the current agent with its state for lightweight parallel execution, including multi-fork N-way parallelism.
  • Use Case: A coordinator agent receives a list of items to process, spawns one worker agent per item, and aggregates all processed results into a single array returned to the caller.

Quick Start

Show me how to fan out a list of tasks to parallel Golem agents in MoonBit and collect their results with promises.

Frequently Asked Questions about golem-parallel-workers-moonbit

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

FAQPage Schema
How do I run tasks in parallel with Golem agents in MoonBit?

Golem agents execute sequentially, so parallelism requires distributing work across multiple agent instances. Spawn child agents with AgentClient::scoped, trigger work fire-and-forget, and collect results by awaiting Golem promises.

What is the difference between child agents and @api.fork() in Golem?

Child agents have persistent identities and suit independent, stateless work, while @api.fork() clones the current agent with its state for ephemeral parallel execution. Forked agents are phantoms without persistent identity.

How do Golem promises work for collecting parallel results?

Create a promise per worker with @api.create_promise, pass each promise ID to a child agent, and have workers call @api.complete_promise with their result. The coordinator calls @api.await_promise for each ID to gather results.

Can I limit concurrency when fanning out to many Golem agents?

Yes, use chunked fan-out by processing items in batches of a fixed size, such as five. Spawn and await each chunk fully before starting the next batch to bound the number of concurrent child agents.

How do I avoid deadlocks between parallel Golem agents?

Never have two agents await each other synchronously. Use fire-and-forget trigger calls to break cyclic waits, and synchronize through promises instead of blocking bidirectional calls.