golem-quota-rust

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Golem agents calling external APIs, LLMs, or shared resources can exceed rate limits, storage budgets, or connection capacity. This Skill shows how to define and enforce distributed resource quotas across all agents in a Golem deployment using the golem_rust::quota module.

Core Features & Use Cases

  • Resource Definition in golem.yaml: Declare Rate, Capacity, and Concurrency limits per environment with reject, throttle, or terminate enforcement actions.
  • QuotaToken Reservations: Acquire a QuotaToken once, then use with_reservation or manual reserve/commit to consume tokens, including variable-cost reservations such as LLM token usage.
  • Token Splitting for Agent RPC: Split quota tokens to pass to child agents and merge returned tokens back, enabling quota-aware agent-to-agent calls.
  • Use Case: An agent calling a third-party API limited to 100 requests per minute defines a Rate resource in golem.yaml, acquires a QuotaToken in its constructor, and wraps each API call in with_reservation so Golem enforces the limit across every running agent replica.

Quick Start

Add a rate-limited resource to my Golem Rust agent so calls to an external API never exceed 100 requests per minute.

Frequently Asked Questions about golem-quota-rust

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

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

Define a Rate limit resource under resourceDefaults in golem.yaml, then acquire a QuotaToken with QuotaToken::new and wrap calls in with_reservation. 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 with_reservation, then return the actual tokens consumed from the closure. Unused reserved capacity is returned to the pool automatically.

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

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

Can I pass a quota token to another Golem agent?

Yes. Use token.split(amount) to create a child QuotaToken, pass it as an agent method parameter since QuotaToken implements IntoValue, and merge the returned token back with token.merge.

Why does my Golem quota reservation fail at runtime?

Failures occur when the resource name in code does not match golem.yaml resourceDefaults, when a reject-enforced resource is exhausted, or when split exceeds the parent's expected use. Verify names match and handle FailedReservation errors.