Repository navigation
feat: Auto-assign subscription to new agents (round-robin) (#74) - #164
Closed
AndriiPasternak31 wants to merge 4 commits into
Closed
AndriiPasternak31 wants to merge 4 commits into
AndriiPasternak31 wants to merge 4 commits into
Conversation
…ai#74) When a new agent is created, Trinity now automatically assigns a subscription using round-robin distribution (fewest agents first, alphabetical tie-break). Falls back to platform API key if no subscriptions exist or token decryption fails. System agents are unaffected (separate creation path). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
get_least_used_subscription() now checks is_subscription_rate_limited() for each candidate, matching the guard in select_best_alternative_subscription(). Prevents auto-assigning a rate-limited subscription to a new agent. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Updated subscription-management.md with Auto-Assign on Creation section documenting the round-robin logic, data flow, and edge cases. Added entry to feature-flows.md index. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
vybe
added a commit
that referenced
this pull request
Mar 25, 2026
New agents are automatically assigned to the subscription with fewest agents (round-robin, alphabetical tie-break). Rate-limited subscriptions are skipped. Falls back to platform API key if no subscriptions exist or token decryption fails. - Added get_least_used_subscription() DB method - Auto-assign logic in create_agent_internal() with graceful fallback - 4 new tests covering no-subs, auto-assign, round-robin, tie-break Closes #74 Co-Authored-By: andrii.pasternak <[email protected]> Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
|
Merged manually via squash to main (fork PR with changelog conflict). Commit: d5864d5 |
10 of 12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
trinity-system) unaffected — separate creation pathChanges
src/backend/db/subscriptions.py— Addedget_least_used_subscription()methodsrc/backend/database.py— Added delegation methodsrc/backend/services/agent_service/crud.py— Auto-assign increate_agent_internal(): lookup before container creation, DB persist afterregister_agent_owner()tests/test_subscriptions.py— 4 new tests (no-subs fallback, auto-assign, round-robin distribution, alphabetical tie-break)docs/memory/changelog.md— Changelog entrydocs/memory/requirements.md— New requirement §20.3adocs/memory/feature-flows/subscription-management.md— Auto-Assign section with data flow diagramTest Plan
pytest tests/test_subscriptions.py::TestSubscriptionAutoAssign -vpytest tests/test_subscriptions.py -vCloses #74
🤖 Generated with Claude Code