golem-add-http-endpoint-scala

Exposes Scala Golem agent methods as HTTP endpoints using mount paths and endpoint annotations.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Scala developers building Golem agents need a code-first way to expose agent methods over HTTP without manually wiring routing infrastructure, including correct path variable mapping, response status codes, and deployment configuration.

Core Features & Use Cases

  • Code-First Route Definitions: Add a mount parameter to @agentDefinition and annotate trait methods with @endpoint(method, path) to define REST routes directly in Scala code.
  • Return Type to HTTP Mapping: Automatically maps Future[Unit], Future[Option[T]], Future[Either[E, T]], and UnstructuredBinary to appropriate HTTP status codes and response bodies.
  • Phantom Agents: Enable phantomAgent = true to create a new agent instance per HTTP request for fully parallel request processing.
  • Use Case: You have a Scala task-management Golem agent and want to expose GET /tasks, POST /tasks, and GET /tasks/{id} as a REST API under a mounted base path, then deploy it via an httpApi section in golem.yaml.

Quick Start

Add HTTP endpoints to my Scala Golem agent by mounting it at a base path and exposing its methods as a REST API.

Frequently Asked Questions about golem-add-http-endpoint-scala

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

FAQPage Schema
How do I expose a Scala Golem agent over HTTP?

Add a mount parameter to @agentDefinition defining the base path, annotate trait methods with @endpoint(method, path), then add an httpApi deployment section to golem.yaml. Build and deploy to make the routes live.

How do path variables map to constructor parameters in Golem Scala agents?

Path variables in the mount path must exactly match the class Id constructor parameter names, including casing. Use camelCase identifiers like {taskName}, never kebab-case like {task-name}, and every constructor parameter must appear in the path.

What HTTP status codes do Golem endpoint return types produce?

Future[Unit] returns 204 No Content, Future[T] returns 200 OK with JSON, Future[Option[T]] returns 404 when None, and Future[Either[E, T]] returns 500 on Left. This mapping is currently not configurable.

Can I use custom case classes in Golem endpoint parameters?

Yes, but all custom types used in endpoint parameters and return values must have a zio.blocks.schema.Schema instance, typically via derives Schema in Scala 3. Use List[T] instead of Array[T], since Array lacks automatic Schema derivation.

What is a phantom agent in Golem HTTP endpoints?

Setting phantomAgent = true on @agentDefinition creates a new agent instance for each HTTP request, enabling fully parallel request processing. It is useful for stateless handlers like webhooks.

Why does my Golem endpoint compilation fail with macro annotation errors?

The @agentDefinition and @endpoint annotations are macros that require the scalacOptions += "-experimental" flag in your build. Also verify the endpoint path starts with / and a mount path exists before using @endpoint.