golem-quota-moonbit

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

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

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 MoonBit agent code using the @quota module.

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 and use with_reservation, reserve/commit, or split/merge to control consumption, including variable-cost reservations like LLM token usage.
  • Agent-to-Agent Quota Sharing: Split quota tokens to pass budget to child agents over RPC and merge returned tokens back.
  • Use Case: An agent calling an LLM reserves 4000 tokens, commits only the actual tokens used, and splits part of its quota to a child summarizer agent, all enforced across the distributed deployment.

Quick Start

Add resource quota definitions to my golem.yaml and show me how to rate limit API calls in my MoonBit Golem agent using @quota.with_reservation.

Frequently Asked Questions about golem-quota-moonbit

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

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

Define a Rate limit under resourceDefaults in golem.yaml, then acquire a QuotaToken with @quota.QuotaToken::new and wrap calls in @quota.with_reservation. The callback returns actual usage so unused capacity returns to the pool.

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

Reserve the maximum expected cost with with_reservation, then commit the actual tokens_used returned by the LLM call. If actual usage is lower than reserved, the unused capacity returns to the quota pool automatically.

What is the difference between reject, throttle, and terminate enforcement?

Reject returns Err(FailedReservation) that the agent must handle, throttle suspends the agent until capacity is available with no code needed, and terminate kills the agent with a failure message.

Can I share quota between Golem agents over RPC?

Yes, call token.split(amount) to create a child QuotaToken and pass it as a parameter to a child agent method. The child uses it for its own reservations, and you merge returned tokens back with token.merge.

Why does QuotaToken split or merge trap at runtime?

Split traps if the child expected use exceeds the parent's current expected use, and merge traps if the two tokens refer to different resources. Acquire the token once, reuse it, and keep resource names matching golem.yaml.

Can I change Golem resource quota limits at runtime?

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