Repository navigation
Description
Summary
Anthropic recently updated pricing, rate limits, and usage tiers for the Claude API alongside the Agent SDK release. Trinity's subscription management (SUB-002) and API key handling (the use_platform_api_key flag, per-agent key injection, MCP key scoping) were designed against the previous model. This spike reviews what needs to change to stay aligned with the new limits and take advantage of any new capabilities the Agent SDK exposes.
Context
Trinity manages Anthropic API access in two ways:
- Platform key — a single Anthropic API key shared across all agents via the
use_platform_api_keyflag inagent_ownership - Per-agent key — operators can inject their own
ANTHROPIC_API_KEYvia the credential system (CRED-002)
The Agent SDK introduces changes to rate limits (per-model, per-tier), usage-based billing signals, and potentially new key scoping semantics. Trinity's subscription layer (SUB-002, routers/subscriptions.py, services/subscription_service.py) may need updating to reflect new tier boundaries, and the platform key pooling strategy may need revisiting if per-key rate limits have changed significantly.
This also connects to the enterprise edition direction (#847) — understanding Anthropic's new limits informs how multi-tenant API key pooling should work at scale.
Acceptance Criteria
- Document Anthropic's new pricing tiers and rate limits (per-model, per-tier, per-key) as they apply to Trinity's usage patterns
- Identify whether the current platform-key-sharing model hits new rate limits at realistic fleet sizes (e.g. 30, 100, 200 agents)
- Assess whether the Agent SDK exposes new API primitives (usage tracking, budget controls, key scoping) that Trinity should surface
- Review
services/subscription_service.pyandrouters/subscriptions.py— identify any hardcoded tier assumptions that need updating - Review
agent_ownership.max_parallel_tasksandexecution_timeout_secondsdefaults against new rate limit shapes - Produce a short recommendation: what changes are required (blocking), what is nice-to-have, and what can be deferred
Technical Notes
- Platform API key config:
src/backend/services/settings_service.py(get_anthropic_api_key) - Per-agent injection:
src/backend/routers/credentials.py - Subscription management:
src/backend/routers/subscriptions.py,src/backend/services/subscription_service.py,src/backend/db/subscriptions.py - Capacity defaults:
agent_ownership.max_parallel_tasks(default 3),agent_ownership.execution_timeout_seconds(default 3600s) - Related: Spike: enterprise edition architecture — private module strategy for compliance features (SSO, SCIM, SIEM) #847 (enterprise edition architecture), Enforce ownership-based subscription scoping #268 (ownership-based subscription scoping), feat: Per-role default token limits for agent interactions #144 (per-role token limits)
- Spike output should be a comment on this issue with a concrete change list
Activity
vybe commentedon Aug 7, 2026
Partial input to this spike (2026-08-07) — findings from a docs review against current Anthropic documentation, relevant to the "does the Agent SDK expose usage/budget primitives" acceptance criterion:
rate_limitsJSON (5h/7dused_percentage+resets_at, https://code.claude.com/docs/en/statusline.md) and the undocumented OAuth usage endpoint already validated byscripts/poc/test-subscription-usage.py(Feb 2026).StopFailurecan matchrate_limit/billing_error— fires post-failure only, so it's a graceful-exit surface, not a throttling one.Promoting to
status-ready(operator call, 2026-08-07) — the subscription half of this spike now has concrete surfaces to review against.vybe commentedon Aug 14, 2026
Partially answered — scoping note, 2026-08-14. Reviewed against the 2026-08-07 premise correction (posted on #471) during the usage-cluster reconciliation. Not closing; one AC is answered, the rest are not.
Answered — AC 3 ("does the SDK/API expose new primitives — usage tracking, budget controls, key scoping — that Trinity should surface"): yes, two, both verified.
GET /api/oauth/usage), proven by this repo's own POCscripts/poc/test-subscription-usage.py— returns 5h/7d utilization, per-model limits, extra-usage status.rate_limitsJSON —five_hour/seven_dayused-percentage plus reset times, zero extra API calls.The consuming work is already filed: feat: Subscription usage observability — 5h/7d usage dashboard, per-agent breakdown, and rate-limit event history #471 (data layer, now P1),
trinity-enterprise#259(tile),trinity-enterprise#351(agent self-awareness). Nothing further needed from this spike on that axis.Still open and still worth the spike — the fleet-scale half nobody has looked at: new tier boundaries and per-key rate limits at realistic fleet sizes (30 / 100 / 200 agents), whether platform-key pooling survives them, hardcoded tier assumptions in
subscription_service.py/routers/subscriptions.py, and themax_parallel_tasks/execution_timeout_secondsdefaults against the new limit shapes.Suggest re-titling to the remaining scope when someone picks it up, so it does not read as still-asking the answered question.
vybe commentedon Aug 19, 2026
Spike partially executed as a side effect of the #471 build gate (2026-08-19) — the provider-signal half of this spike now has real payloads:
GET https://api.anthropic.com/api/oauth/usagewith a storedclaude setup-tokentoken (sk-ant-oat01-) → 403permission_error: OAuth token does not meet scope requirement user:profile. Mechanism established: setup tokens are inference-scoped; the endpoint requiresuser:profile, which only interactive-login tokens carry. Any design assuming Trinity can poll that endpoint with stored credentials is dead on arrival (confirms Show Claude subscription usage without metered cost #2170's post-mortem with the exact reason).POST /v1/messagesunder the same token returns the unified rate-limit header set (anthropic-ratelimit-unified-{5h,7d}-utilization/-reset/-status,representative-claim, overage status/reason) — real remaining-budget data, per subscription, centrally reachable. feat: Subscription usage observability — 5h/7d usage dashboard, per-agent breakdown, and rate-limit event history #471 builds its headroom layer on this channel (micro-ping probe +source: anthropic|observedcontract).Remaining for this spike: the pricing/limits policy review against the Agent SDK terms, and whether an officially documented usage surface for setup tokens appears (which would retire the probe).
vybe commentedon Nov 24, 2026
This spike is now the blocker for a customer-facing answer, not just an internal alignment check.
Operators are reaching the Connect Claude step and asking, before they buy anything, roughly what a handful of agents will consume so they can pick the right plan tier — and nothing published answers it. Observed consumption and the per-agent cost breakdown in
Settings → Integrationsanswer it only in hindsight, after a plan is already bought, and the weekly-limit alert warns at 75% of a window the operator has already committed to.The acceptance criteria here already cover the two inputs that answer would need — current per-tier pricing and rate limits as they apply to Trinity's usage patterns, and whether the model holds at realistic fleet sizes. I have filed the publishing half separately as #4748 (a "choosing a Claude credential" section plus sizing guidance in the credential guides) and marked it as depending on this spike for the numbers, deliberately rather than guessing a figure ahead of it.
Two things have moved since this was last updated (2026-09-24) and are worth folding into the spike's scope when it runs:
Also for the record, verified on
devatc62030cf: the capacity defaults this issue asks to review are unchanged —max_parallel_tasksdefault 3 (db/schema.py,db/agent_settings/resources.py), fleet ceiling default 10. Since #1027 the backend's own small model calls go throughservices/model_gateway.pyand a job attributed to a subscription-mode agent consumes that agent's subscription, which is consumption the original framing of this issue (platform key only, per-agent injection) predates.No priority change requested.