golem-call-another-agent-rust

Implements agent-to-agent RPC calls with awaited results in Rust 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-rust
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golem-call-another-agent-rust
Source: https://github.com/golemcloud/golem/tree/main/golem-skills/skills/rust/golem-call-another-agent-rust
Command: npx skills add https://github.com/golemcloud/golem --skill golem-call-another-agent-rust

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

When building distributed agent systems on Golem, one agent often needs to invoke another agent and wait for its result. This Skill explains how to use the auto-generated client types from the #[agent_definition] macro to perform blocking agent-to-agent RPC calls in Rust, including cross-component communication and deadlock avoidance.

Core Features & Use Cases

  • Generated Client Types: Obtain a <AgentName>Client via Client::get(...) using the target agent's constructor parameters, without explicitly creating the agent.
  • Awaited RPC Calls: Call methods on the client and await results, blocking the calling agent until the target responds.
  • Cross-Component RPC: Call agents defined in other components after golem build generates bridge SDK code from dependencies declared in golem.yaml.
  • Use Case: A coordinator agent needs the current count from a counter agent. It calls CounterAgentClient::get("my-counter".to_string()) and then awaits counter.get_count() to retrieve the value synchronously.

Quick Start

Show me how to call another Golem agent from my Rust agent and await its result using the generated client.

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

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

FAQPage Schema
How do I call another agent from a Rust Golem agent?

Use the auto-generated `<AgentName>Client` type produced by the `#[agent_definition]` macro. Call `Client::get(...)` with the target agent's constructor parameters, then invoke methods on the client and await the results.

How does agent-to-agent RPC work in Golem?

The calling agent obtains a client handle and invokes a method, which blocks until the target agent processes the request and returns a result. The target agent is created implicitly on first invocation if it does not already exist.

Can I call agents defined in a different Golem component?

Yes. Declare the dependency in `golem.yaml` and run `golem build`, which generates bridge SDK code for inter-component dependencies. The generated client type for the remote agent then becomes available in your Rust project.

Does Client::get create a new agent instance?

No. `Client::get(...)` does not create the agent; the agent is created implicitly on its first invocation. If an agent with those constructor parameters already exists, you receive a handle to the existing instance.

Why does my agent-to-agent call deadlock in Golem?

Deadlocks occur when agents form RPC cycles, such as A awaiting B while B awaits A. Break cycles by using fire-and-forget `trigger_` calls instead of awaited calls in one direction.

How do I create multiple agent instances with the same constructor parameters?

Use phantom agents, which allow multiple distinct instances sharing the same constructor parameters. This is covered separately from standard awaited RPC calls.