golem-add-agent-moonbit

Creates new MoonBit agent definitions for Golem WebAssembly components.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Defining a new durable, stateful agent in a MoonBit Golem project requires knowing the exact struct annotations, constructor conventions, and schema derivation rules. This Skill guides the creation of a correctly structured agent so it compiles and behaves properly on the Golem platform.

Core Features & Use Cases

  • Agent Struct Definition: Creates a new agent file with a struct annotated with #derive.agent, a constructor, and public methods.
  • Custom Schema Types: Adds #derive.golem_schema annotations to custom structs and enums used in method signatures.
  • Error Handling Guidance: Distinguishes domain errors returned via Result[T, E] from uncaught errors that trigger retries and agent failure.
  • Use Case: When building a WebAssembly-based distributed application on Golem with MoonBit, use this Skill to add a new agent type such as a Wallet with deposit and withdraw methods that return typed domain errors.

Quick Start

Add a new MoonBit agent called Counter with an increment method to my Golem component and verify it builds.

Frequently Asked Questions about golem-add-agent-moonbit

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

FAQPage Schema
How do I add a new agent to a MoonBit Golem project?

Create a new file src/<agent_name>.mbt, define a struct annotated with #derive.agent, add a constructor fn AgentName::new(...), and expose behavior with pub fn methods. Run golem build to verify the component compiles.

How do I return errors from a Golem agent method in MoonBit?

Return domain errors as values using Result[T, E] with a custom error enum annotated with #derive.golem_schema. Uncaught exceptions are treated as crashes, triggering retries and eventually failing the agent instead of returning an error to the caller.

Can custom structs be used in Golem agent method signatures?

Yes, custom structs and enums can be used as parameter or return types if they are annotated with #derive.golem_schema. This gives them the schema support required by the Golem runtime.

Why should I not edit golem_reexports.mbt or golem_agents.mbt?

These files, along with golem_derive.mbt, are auto-generated by golem build. Manual edits are overwritten on the next build, so all agent logic must live in your own source files.

How are Golem agents identified and created?

Constructor parameters form the agent identity, so two agents with the same parameters are the same agent. Agents are created implicitly on first invocation, with no separate creation step, and invocations run sequentially in a single thread.