Skip to content

Add Memory & CPU Quota Limits to DockerSandbox #6

Description

@Kaap10

Description

When evaluating coding agents with DockerSandbox, an agent's code could consume excessive memory or CPU (e.g., through infinite loops, recursion, or memory leaks). DockerSandbox should enforce configurable resource quotas.

Proposed Solution

  1. Add DOCKER_MEMORY_LIMIT (default "2g") and DOCKER_CPU_QUOTA (default 1.0) settings to backend/app/config/settings.py.
  2. Update backend/app/sandbox/docker_sandbox.py to pass mem_limit and nano_cpus parameters when spawning Docker containers via docker.containers.run().
  3. Add a unit test verifying container creation arguments.

Relevant Files

  • backend/app/sandbox/docker_sandbox.py
  • backend/app/config/settings.py

Acceptance Criteria

  • Containers spawned by DockerSandbox enforce configured memory and CPU limits.
  • Configurable via .env environment variables.
  • Unit tests pass with python -m pytest.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions