golem-make-http-request-scala

Implements outgoing HTTP requests from Scala Golem agents using fetch or ZIO HTTP.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires zio-http.

What problem does it solve?

Scala Golem agents compile to JavaScript via Scala.js and run in a QuickJS-based WASM runtime, so standard JVM HTTP clients do not work. This Skill shows how to make outgoing HTTP requests correctly from agent code and how to make Golem retry failed requests.

Core Features & Use Cases

  • Fetch via Scala.js: Call the global fetch API through js.Dynamic for simple GET and POST requests returning Futures.
  • ZIO HTTP client: Use zio-http for typed HTTP calls inside ZIO-based agents.
  • Status-code retry policies: Configure named retry policies in golem.yaml so the host transparently retries 5xx responses, with Guards.atomically as a fallback for application-level retry triggers.
  • Use Case: A weather agent endpoint calls an external API with fetch, parses the JSON response, and relies on a status-code retry policy to re-send the request on 500/502/503/504 responses.

Quick Start

Show me how to make a POST request with a JSON body from my Scala Golem agent and retry it automatically on 5xx responses.

Frequently Asked Questions about golem-make-http-request-scala

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

FAQPage Schema
How do I make an HTTP request from a Scala Golem agent?

Use the global fetch API through Scala.js interop: call js.Dynamic.global.fetch with a js.Dynamic.literal options object and convert the resulting js.Promise to a Scala Future. For ZIO-based agents, use the zio-http Client instead.

Should I use fetch or ZIO HTTP in a Scala Golem agent?

Use fetch via Scala.js for simple requests since it is available as a global function with no extra dependencies. Use zio-http when your agent already uses ZIO, as it provides a typed Scala API over the same WASI HTTP layer.

Can I use Apache HttpClient or OkHttp in a Golem Scala agent?

No. Golem Scala agents compile to JavaScript via Scala.js, so JVM HTTP clients like Apache HttpClient, OkHttp, and sttp with non-JS backends will not work. All libraries must be Scala.js-compatible, declared with %%% in build.sbt.

How do I retry an HTTP request on 500 errors in Golem?

Define a named retry policy in golem.yaml whose predicate references status-code with values like 500, 502, 503, 504. The host transparently re-sends the request, and plain POST calls are eligible by default since idempotence mode defaults to true.

Why does my POST to a Golem agent endpoint fail with a text body?

Golem agent endpoints deserialize non-binary bodies from a JSON object where each field matches a method parameter name. Send application/json with a body like {"body": "a"} instead of a raw text string.