golem-multi-instance-agent-rust

Creates multiple independent Golem agent instances sharing constructor parameters using phantom IDs in Rust.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

In Golem, an agent is normally uniquely identified by its constructor parameters, so calling get with the same values always returns the same agent. This Skill explains how to use phantom agents in Rust to create multiple distinct, durable agent instances that share identical constructor parameters by appending a phantom UUID to the agent identity.

Core Features & Use Cases

  • Phantom Instance Creation: Use the generated client methods new_phantom and get_phantom to create or reconnect to independent agent instances with random or specific UUIDs.
  • Phantom ID Introspection: Query an agent's own phantom ID from inside the agent via the BaseAgent trait's phantom_id method.
  • HTTP-Mounted Phantom Agents: Set phantom_agent = true on an HTTP-mounted agent so every incoming request is handled by a fresh instance.
  • Use Case: Imagine a chat application where each user session needs its own Counter agent with the same configuration. Use new_phantom to spawn an isolated instance per session, store the returned UUID, and reconnect later with get_phantom.

Quick Start

Show me how to create and reconnect to phantom agent instances in Rust using new_phantom and get_phantom with the Golem agent client.

Frequently Asked Questions about golem-multi-instance-agent-rust

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

FAQPage Schema
How do I create multiple agent instances with the same parameters in Golem Rust?

Use phantom agents via the generated client methods. Call new_phantom(params) to create a new independent instance with a random UUID, or get_phantom(uuid, params) to reconnect to a specific existing phantom instance.

What is the difference between get and get_phantom in Golem agent clients?

The get method returns a non-phantom agent identified solely by its constructor parameters, so identical parameters always return the same agent. get_phantom adds a UUID to the identity, so each UUID produces a distinct agent even with identical parameters.

How can a Golem agent get its own phantom ID in Rust?

An agent queries its own phantom ID through the BaseAgent trait by calling self.phantom_id(). It returns Some(uuid) for phantom agents and None for non-phantom agents.

Can Golem phantom agents handle each HTTP request with a new instance?

Yes. Set phantom_agent = true in the agent_definition macro along with an HTTP mount path. Every incoming HTTP request then creates a fresh phantom instance with its own UUID, even though constructor parameters are identical.

Do phantom agents in Golem persist state like regular agents?

Yes, phantom agents are fully durable and persist just like regular agents. However, phantom and non-phantom agents with the same constructor parameters are different agents and do not share state.