Hermes Multi-Agent API Rate Limiting with flock
Preface
In Hermes multi-Agent collaborative tasks, I only have one Nous Portal account,
and the gateways of these agents are independent, so it is possible that API requests are concentrated in a short period of time, and Nous Portal returns a 429 Too Many Requests error code.
Approach
Start the next request only after one API request is completed?
Use a separate process to control the rate of API requests?
Hermes (via mimo-v2-pro model) gave me a better implementation plan
Use flock file lock + status file:
~/.hermes/api_rate_limit → content: timestamp of the last request
When Gateway wants to call the API:
flock(api_rate_limit.lock)
read(last_time)
if now - last_time >= interval:
write(now) ← Update timestamp
unlock
→ Send API request
else:
wait_time = interval - (now - last_time)
unlock
sleep(wait_time)
→ Retry
No additional process is needed; each gateway just checks before calling the API. All agents share the same file, and flock ensures mutually exclusive read/write.
I ended up using the above solution.
It works pretty well.
======
Postscript
Compared with openclaw, all agents are in one openclaw system, you can see that multiple agent definitions are specified in one config.json.
So these agents are inherently connected to the same model provider. When using the same OAuth account, of course the global request rate can be controlled.
========
update
Github
========