golem-call-another-agent-moonbit

Implements agent-to-agent RPC calls with auto-generated clients in MoonBit Golem projects.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Building distributed agent systems in Golem requires agents to communicate with each other, but managing remote procedure calls, client lifecycles, and cross-component dependencies manually is error-prone and can lead to resource leaks or deadlocks.

Core Features & Use Cases

  • Scoped Client Pattern: Use <AgentName>Client::scoped(...) to obtain a client that is automatically dropped when the callback returns, preventing resource leaks.
  • Manual Client Management: Use <AgentName>Client::get(...) with an explicit drop() call when you need full control over the client lifecycle.
  • Cross-Component RPC: Call agents defined in other components after running golem build, which generates bridge SDK code from dependencies declared in golem.yaml.
  • Use Case: A task-manager agent needs to update a counter agent and read back the result. Use CounterClient::scoped("my-counter", ...) to increment the counter and await the returned value in a single blocking call.

Quick Start

Ask the AI to show how to call another Golem agent from a MoonBit agent using the scoped client pattern and await the result.

Frequently Asked Questions about golem-call-another-agent-moonbit

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

FAQPage Schema
How do I call another agent in a MoonBit Golem project?

Use the auto-generated `<AgentName>Client` struct created by the #derive.agent code generation tool. Call `Client::scoped(...)` with the target agent's constructor parameters and a callback, then invoke methods inside the callback and await the returned result.

What is the difference between scoped and get client patterns in Golem?

The scoped pattern automatically drops the client when the callback returns, making it the recommended approach. The get pattern gives manual lifecycle control but requires you to explicitly call `client.drop()` when finished to avoid leaking resources.

Can I call agents defined in a different Golem component?

Yes, cross-component RPC is supported. Declare the dependency in golem.yaml and run golem build, which generates bridge SDK code including the client type for the remote component's agents.

Does calling another agent create a new instance?

No, obtaining a client does not create the agent. The agent is created implicitly on its first invocation; if it already exists, the client is a handle to the existing instance.

Why do agent-to-agent calls deadlock in Golem?

Deadlocks occur when agents form RPC cycles, such as agent A awaiting agent B while B awaits A. Break cycles by using fire-and-forget trigger calls instead of awaited calls for one direction of the communication.