Skip to content

chore(llm-gateway): add signals user cost limits#59433

Merged
joshsny merged 1 commit into
masterfrom
posthog-code/llm-gateway-signals-cost-limits
May 21, 2026
Merged

chore(llm-gateway): add signals user cost limits#59433
joshsny merged 1 commit into
masterfrom
posthog-code/llm-gateway-signals-cost-limits

Conversation

@joshsny
Copy link
Copy Markdown
Contributor

@joshsny joshsny commented May 21, 2026

Problem

We recently split signals/report-generation traffic out of the larger ai_product = signals cost-tracking bucket, but the signals product in the LLM gateway has no explicit entry in DEFAULT_USER_COST_LIMITS. It falls back to the global default ($100 USD per 24h burst), which is too low for report-generation runs and risks hitting the per-user burst limit before a single report finishes.

Changes

Add an explicit UserCostLimit for the signals product in services/llm-gateway/src/llm_gateway/config.py:

  • burst limit: $500 USD / 7 days
  • sustained limit: $1000 USD / 30 days

(Mirrors the cadence we use for background_agents.)

No product-wide (product_cost_limits) entry is added — the existing fallback ($1000/24h) is still applied via ProductCostThrottle._get_limit_and_window.

How did you test this code?

I'm an agent. I ran ruff check and ruff format --check on the changed file. I did not run the gateway test suite (requires Redis).

Publish to changelog?

no

Docs update

n/a — internal config only.

🤖 Agent context

Authored by PostHog Code on behalf of Josh Snyder. Origin: a Slack thread asking how to track signals LLM cost now that session-summary spend was pulled out of ai_product = signals. We confirmed that signals exists as a product in the gateway (services/llm-gateway/src/llm_gateway/products/config.py) and is OAuth-gated to the PostHog Code apps, but had no user cost limit override, so it was inheriting the conservative $100/24h default. This PR aligns it with the cadence we use for the other internal-task product (background_agents).

Paired with posthog/code#TBD which routes internal signal_report tasks to the signals gateway product.


Created with PostHog Code

Add explicit per-user cost limits for the signals product: $500 USD
burst over 7 days, $1000 USD sustained over 30 days. Without an entry
in DEFAULT_USER_COST_LIMITS, signals was falling back to the default
$100/24h burst, which is too low for report-generation runs.

Generated-By: PostHog Code
Task-Id: 31cea4e3-e0d7-49e7-bd01-d41bcafabe53
@joshsny joshsny marked this pull request as ready for review May 21, 2026 15:36
Copilot AI review requested due to automatic review settings May 21, 2026 15:36
@joshsny joshsny merged commit 3ac9c0f into master May 21, 2026
151 checks passed
@joshsny joshsny deleted the posthog-code/llm-gateway-signals-cost-limits branch May 21, 2026 15:37
@assign-reviewers-posthog assign-reviewers-posthog Bot requested a review from a team May 21, 2026 15:37
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 21, 2026

Reviews (1): Last reviewed commit: "chore(llm-gateway): add signals user cos..." | Re-trigger Greptile

@joshsny joshsny review requested due to automatic review settings May 21, 2026 15:58
@deployment-status-posthog
Copy link
Copy Markdown

deployment-status-posthog Bot commented May 21, 2026

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-05-21 16:17 UTC Run
prod-us ✅ Deployed 2026-05-21 16:40 UTC Run
prod-eu ✅ Deployed 2026-05-21 16:52 UTC Run

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants