golem-call-another-agent-scala

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Coordinating work between agents in a Golem application requires calling remote agents and awaiting their results, but doing this incorrectly can cause deadlocks or misuse of the generated client APIs. This Skill provides the exact patterns for agent-to-agent RPC in Scala Golem projects.

Core Features & Use Cases

  • Awaited RPC Calls: Obtain a generated client via CounterAgentClient.get(...) and call methods that return genuinely async Future results while the calling agent suspends.
  • Multiple Call Modes: Use cancelable calls returning a (Future, CancellationToken) pair, fire-and-forget .trigger() calls, and scheduled invocations with scheduleAt.
  • Cross-Component RPC: Call agents defined in other components using bridge SDK code generated by golem build from dependencies declared in golem.yaml.
  • Use Case: An orchestrator agent needs to increment a counter agent and read its state. Use this Skill to get the client, await increment() and getCount() concurrently, and avoid RPC cycles that deadlock both agents.

Quick Start

Show me how to call another Golem agent from my Scala agent and await the result without deadlocking.

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

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

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

Define the agent trait with @agentDefinition, then use the generated companion client like CounterAgentClient.get("my-counter") to obtain a remote handle. Calling its methods returns a Future that suspends the calling agent until the target responds.

How do I cancel a pending agent RPC call in Golem?

Use the cancelable variant of a method, such as counter.increment.cancelable(), which returns a (Future[Out], CancellationToken) pair. Call token.cancel() later for best-effort cancellation of the pending invocation.

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 providing the client type for agents in the other component.

Why do my Golem agents deadlock when calling each other?

Deadlocks occur when agent A awaits agent B while B awaits A, creating an RPC cycle. Break the cycle by using .trigger() fire-and-forget calls on one side so neither agent suspends waiting on the other.

Does getting an agent client create the agent instance?

No, CounterAgentClient.get(...) only returns a handle. The agent is created implicitly on its first invocation, and if it already exists you receive a handle to the existing instance.