golem-parallel-workers-scala

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

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

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 Scala Golem project and aggregate the results.

Core Features & Use Cases

  • Child Agent Fan-Out: Spawn child agents via codegen-generated XClient.get(id), dispatch work, and collect results with Future.sequence or Golem promises.
  • Agent Forking: Clone the current agent at the current execution point with HostApi.fork() for lightweight parallelism where forked copies inherit state.
  • Error Handling and Batching: Chunk fan-out to limit concurrency and use recover for partial-failure collection.
  • Use Case: A coordinator agent receives a list of regions, spawns one worker agent per region to generate reports in parallel, and aggregates all reports into a single result.

Quick Start

Show me how to fan out work to multiple parallel Golem agents in Scala and collect their results.

Frequently Asked Questions about golem-parallel-workers-scala

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

FAQPage Schema
How do I run work in parallel with Golem agents in Scala?

Golem agents execute sequentially, so parallelism is achieved by spawning multiple child agent instances via the codegen-generated XClient.get(id) and collecting their Futures with Future.sequence. Alternatively, use HostApi.fork() to clone the current agent for lightweight parallel execution.

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

Child agents have persistent identity and suit independent, stateless work, while fork() clones the current agent with its state into an ephemeral phantom instance. Use child agents when workers need their own ID, and fork() when workers must inherit the parent's current state.

How do I collect results from parallel Golem agents?

Use Future.sequence to combine the Futures returned by child agent calls into a single list of results. For fire-and-forget dispatch, create a Golem promise per child with HostApi.createPromise() and await each with HostApi.awaitPromise or awaitPromiseJson.

How do I handle partial failures when fanning out to Golem workers?

Wrap each child call with .map(Right(_)).recover to capture failures as Left values, then partition the sequenced results into successes and failures. This lets the coordinator return partial results instead of failing the entire fan-out.

Can Golem agents deadlock when waiting on each other?

Yes, two agents synchronously awaiting each other can deadlock. Break cycles by using .trigger for fire-and-forget invocation combined with Golem promises, so agents suspend on promise completion rather than blocking on direct RPC.