golem-quota-scala

Implements distributed resource quotas and rate limiting in Scala Golem agents.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Golem agents calling external APIs, LLMs, or shared resources need enforced limits on consumption. This Skill shows how to define rate, capacity, and concurrency quotas in golem.yaml and enforce them in Scala agent code using the QuotaApi.

Core Features & Use Cases

  • Quota Definition: Declare Rate, Capacity, and Concurrency limits per environment in golem.yaml with reject, throttle, or terminate enforcement actions.
  • Token-Based Enforcement: Acquire a QuotaToken once, then use withReservation, reserve/commit, or split/merge to control consumption, including variable-cost reservations for LLM token usage.
  • Use Case: An agent calling an LLM reserves 4000 tokens upfront, commits only the actual tokens used, and splits a portion of its quota to a child agent invoked over RPC.

Quick Start

Add rate limiting to my Scala Golem agent so it makes at most 100 API calls per minute using a quota token.

Frequently Asked Questions about golem-quota-scala

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

FAQPage Schema
How do I add rate limiting to a Scala Golem agent?

Define a Rate limit under resourceDefaults in golem.yaml, then acquire a QuotaToken for that resource and wrap calls in withReservation. Golem enforces the limit across all agents in the deployment.

How do I limit LLM token usage in a Golem agent?

Reserve the maximum expected cost with withReservation, then commit the actual tokens used from the response. Unused reserved capacity returns to the pool automatically.

What is the difference between reject and throttle enforcement in Golem quotas?

Reject returns Left(FailedReservation) that the agent must handle, optionally with an estimated wait time. Throttle suspends the agent until capacity is available, requiring no error-handling code.

Can I share quota between Golem agents over RPC?

Yes. Call token.split(amount) to create a child QuotaToken, pass it as a parameter to the child agent, and merge the returned token back with token.merge. Split traps if the amount exceeds the parent's expected use.

Can Golem resource limits be changed at runtime?

Yes. Use the golem resource update CLI command with a new limit definition and target environment. Changes take effect immediately for running agents without redeployment.