MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / checkSendLimit

Method checkSendLimit

internal/httpapi/outbound.go:417–432  ·  view source on GitHub ↗

checkSendLimit applies the per-agent outbound rate limit (mirrors the legacy sendLimit). On block it returns a 429 envelope carrying the retry-after seconds; the IETF RateLimit-* response headers are a tracked follow-up (Huma error responses can't set headers directly).

(agentID string)

Source from the content-addressed store, hash-verified

415// retry-after seconds; the IETF RateLimit-* response headers are a tracked
416// follow-up (Huma error responses can't set headers directly).
417func (s *Server) checkSendLimit(agentID string) *ErrorEnvelope {
418 if s.deps.SendLimit == nil {
419 return nil
420 }
421 ok, retryAfter := s.deps.SendLimit(agentID)
422 if ok {
423 return nil
424 }
425 secs := int(retryAfter.Round(time.Second).Seconds())
426 if secs < 1 {
427 secs = 1
428 }
429 return NewError(http.StatusTooManyRequests, "rate_limited",
430 "rate limit exceeded — max 60 sends per minute per agent").
431 WithDetails(map[string]any{"retry_after_seconds": secs})
432}
433
434func (s *Server) handleCreateMessage(ctx context.Context, in *createMessageInput) (*sendOutput, error) {
435 ag, err := s.resolveOwnedAgent(ctx, in.Address)

Callers 3

approveHeldMethod · 0.95
handleTestSendMethod · 0.95
deliverMethod · 0.95

Calls 2

NewErrorFunction · 0.85
WithDetailsMethod · 0.80

Tested by

no test coverage detected