Skip to content

feat(resources): system-wide agent CPU/memory defaults (#611)#613

Merged
vybe merged 3 commits into
devfrom
feature/611-agent-resource-limits
Apr 30, 2026
Merged

feat(resources): system-wide agent CPU/memory defaults (#611)#613
vybe merged 3 commits into
devfrom
feature/611-agent-resource-limits

Conversation

@vybe

@vybe vybe commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds GET/PUT /api/settings/agent-defaults/resources (admin-only) so instance admins can set fleet-wide CPU and memory defaults for new agent containers
  • CPU is specified as whole number of processors (1, 2, 4, 8, 16) — not fractional
  • Container creation now uses a 3-tier fallback: per-agent DB limit → system default → hardcoded safe value
  • Fixes pre-existing 4Gi4g bug in crud.py (Docker API rejects IEC suffix)
  • Tightens fallback ordering in lifecycle.py to slot system defaults between DB overrides and container labels

Changes

  • services/settings_service.pyget_agent_default_resources() + AGENT_DEFAULT_* constants
  • routers/settings.pyGET/PUT /api/settings/agent-defaults/resources endpoints
  • services/agent_service/crud.py — apply system defaults at creation, fix 4Gi4g
  • services/agent_service/lifecycle.py — apply system defaults at container recreation
  • tests/test_settings.pyTestAgentDefaultResources (9 tests: auth, CRUD, validation, partial update)

Test Plan

  • pytest tests/test_settings.py -k AgentDefaultResources -v
  • GET /api/settings/agent-defaults/resources → returns cpu, memory, valid_* enumerations
  • PUT /api/settings/agent-defaults/resources with {"cpu": "4"} → new agents created with 4 CPUs
  • PUT with {"cpu": "0.5"} or {"memory": "4Gi"} → 400 rejected
  • Create agent without per-agent limit → container uses system default
  • Per-agent PUT /api/agents/{name}/resources → overrides system default on restart

Fixes #611

🤖 Generated with Claude Code

vybe and others added 3 commits April 30, 2026 20:34
…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>
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.

1 participant