Skip to content

feat(self_hosted_hub): add per-org rate limiting for agent register/disconnect#1118

Open
loadez wants to merge 1 commit into
mainfrom
self-hosted-hub/register-rate-limit
Open

feat(self_hosted_hub): add per-org rate limiting for agent register/disconnect#1118
loadez wants to merge 1 commit into
mainfrom
self-hosted-hub/register-rate-limit

Conversation

@loadez

@loadez loadez commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

No description provided.

…isconnect

Adds a feature-flagged, per-pod in-memory token-bucket limiter keyed by
organization, applied to the agent register and disconnect handlers. Disabled
by default; when enabled the limit is per-pod, so the effective cluster-wide
rate is the configured value times the replica count. Emits
agent.register.rate_limited / agent.disconnect.rate_limited counters per org.
Admin bulk operations on the internal API are unaffected.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 296751daa6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// Smooth per-org disconnect churn. See the note on Register; same per-pod
// limiter, and admin bulk operations on the internal API are unaffected.
orgID := agent.OrganizationID.String()
if !s.rateLimiter.Allow(orgID) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep disconnects out of the register bucket

When rate limiting is enabled, this uses the same per-org bucket that Register consumes, so a burst of successful registrations can empty the bucket and cause the agents' immediate /disconnect calls to return 429 before agent.DisconnectWithContext runs. Those agents remain in registered state and are still counted by agentcounter.countAgentsInOrganization, so normal batch/single-job churn can temporarily exhaust quota or show stale agents; use separate endpoint buckets or let disconnect cleanup bypass the register limiter.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant