feat(resources): system-wide agent CPU/memory defaults (#611)#613
Merged
Conversation
…gent override Adds GET/PUT /api/settings/agent-defaults/resources (admin-only) so instance admins can set fleet-wide CPU (number of processors) and memory limits. Container creation falls back: per-agent DB limit → system default → hardcoded. Also fixes pre-existing '4Gi' → '4g' bug in crud.py (Docker rejects IEC suffix) and tightens the fallback ordering in lifecycle.py to include system defaults. Fixes #611 Co-Authored-By: Claude <noreply@anthropic.com>
…stem defaults Co-Authored-By: Claude <noreply@anthropic.com>
- Update requirements.md req 16.1 with RES-001 system-defaults description - Add GET/PUT /api/settings/agent-defaults/resources to architecture.md - Move AgentDefaultResourcesUpdate from settings.py to models.py (Invariant #14) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
GET/PUT /api/settings/agent-defaults/resources(admin-only) so instance admins can set fleet-wide CPU and memory defaults for new agent containers4Gi→4gbug incrud.py(Docker API rejects IEC suffix)lifecycle.pyto slot system defaults between DB overrides and container labelsChanges
services/settings_service.py—get_agent_default_resources()+AGENT_DEFAULT_*constantsrouters/settings.py—GET/PUT /api/settings/agent-defaults/resourcesendpointsservices/agent_service/crud.py— apply system defaults at creation, fix4Gi→4gservices/agent_service/lifecycle.py— apply system defaults at container recreationtests/test_settings.py—TestAgentDefaultResources(9 tests: auth, CRUD, validation, partial update)Test Plan
pytest tests/test_settings.py -k AgentDefaultResources -vGET /api/settings/agent-defaults/resources→ returnscpu,memory,valid_*enumerationsPUT /api/settings/agent-defaults/resourceswith{"cpu": "4"}→ new agents created with 4 CPUsPUTwith{"cpu": "0.5"}or{"memory": "4Gi"}→ 400 rejectedPUT /api/agents/{name}/resources→ overrides system default on restartFixes #611
🤖 Generated with Claude Code