golem-add-agent-rust

Creates new Rust agent types for Golem components using agent_definition and agent_implementation macros.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Defining a new durable, stateful agent in a Rust Golem component requires following specific conventions—annotated traits, implementation structs, Schema-derived types, and correct error handling—that are easy to get wrong without guidance.

Core Features & Use Cases

  • Agent scaffolding: Guides creation of the agent module, the #[agent_definition] trait, the #[agent_implementation] struct, and re-exports from lib.rs.
  • Custom type support: Shows how to derive Schema, Serialize, and Deserialize so custom parameter and return types work with agent methods.
  • Domain error handling: Explains returning Result<T, E> for expected failures versus uncaught errors that trigger retries and agent failure.
  • Use Case: When building a Golem application, ask to add a new Wallet agent with deposit and withdraw methods, and get a complete, buildable Rust implementation verified with golem build.

Quick Start

Add a new Rust agent named Counter with increment and get methods to my Golem component.

Frequently Asked Questions about golem-add-agent-rust

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

FAQPage Schema
How do I add a new agent to a Rust Golem component?

Create a new module file, define a trait annotated with #[agent_definition], implement it on a struct with #[agent_implementation], re-export it from lib.rs, and run golem build to verify the component compiles.

How do I define custom types for Golem agent methods in Rust?

Custom parameter and return types must derive the Schema trait from golem_rust along with serde Serialize and Deserialize. Schema implies IntoValue and FromValueAndType, so no extra derives are needed.

How do Golem agents handle errors in Rust?

Domain errors should be returned as Result<T, E> where E derives Schema, so callers receive the failure as a value. Panics or unwrapped errors are treated as crashes, triggering retries and eventually failing the agent.

Can I use block_on inside a Golem agent method?

No, block_on must never be used because all agent methods run in an async context. Define methods as async and use .await instead of blocking on futures.

What determines the identity of a Golem agent?

Constructor parameters form the agent's identity, so two agents created with the same parameters are the same agent. Agents are created implicitly on first invocation with no separate creation step.