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)
| 415 | // retry-after seconds; the IETF RateLimit-* response headers are a tracked |
| 416 | // follow-up (Huma error responses can't set headers directly). |
| 417 | func (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 | |
| 434 | func (s *Server) handleCreateMessage(ctx context.Context, in *createMessageInput) (*sendOutput, error) { |
| 435 | ag, err := s.resolveOwnedAgent(ctx, in.Address) |
no test coverage detected