Golem call tool scala

From golemcloud/golem · View interactive version

Golem call tool scala is an AI agent skill from the GitHub repository golemcloud/golem. Calls a generated typed Golem tool client from Scala. Use when invoking built-in or MCP imported tools, a tool provider, or handling tool errors.

How to use this skill

Skill file

Call a Golem tool from Scala

Call an existing tool through a generated client

Load golem-generating-tool-clients to select a built-in release or MCP import and

add it to the Scala component's dependencies.tools. Configure its runtime binding

separately. golem build automatically generates the client without an explicit

bridge selection. Include the generated sources in the consumer build.

In the standard sbt template, add this setting to the consumer project's existing

.settings(...) block. LocalRootProject resolves the application root rather

than the component directory:

Compile / unmanagedSourceDirectories += (LocalRootProject / baseDirectory).value /
  "golem-temp/bridge-sdk/scala/internal/bash-tool-guest-client/src/main/scala"

Call the built-in bash release 0.2.1 inside an agent method:

import golem.bridge.client.bash.BashClient

val pending = BashClient().run("printf 'hello\\n'", "", golem.UInt(600L))

pending is a Future of an Either: handle the tool failure or inspect the

result's stdout, stderr, and exit code. Bash returns those strings in its result,

not stream handles. For streaming commands, use the invocation's collect() to

drain both channels concurrently and check each outcome.

Call from a definition owned by the application

@toolDefinition generates <Tool>Client. Construct it with the generated factory and call the

typed asynchronous methods:

import golem.tool.ToolError
import scala.concurrent.Future

val client: EchoClient = EchoClient()
val result: Future[Either[ToolError[Nothing], String]] =
  client.echo("hello")

Use the exact generated signature: a command with declared errors uses the error type declared by

the tool method instead of Nothing. Commands without stdout or stderr, including stdin-only

commands, return Future[Either[ToolError[E], A]]; stdin is a ToolInputStream parameter. A command

with either output returns Either[ToolError[E], ToolInvocation[E, A]], whose invocation exposes

the result and independent stdout/stderr streams. Drain both outputs concurrently. Handle

ToolError.Tool separately from protocol failures. Never edit generated clients.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.