Skip to content

fix(sessions): derive default capacity from RAM - #684

Merged
lionello merged 1 commit into
masterfrom
fix/ram-derived-session-limit
Sep 12, 2026
Merged

fix(sessions): derive default capacity from RAM#684
lionello merged 1 commit into
masterfrom
fix/ram-derived-session-limit

Conversation

@defangdevs

Copy link
Copy Markdown
Owner

Why

Issue #662 specified a default budget of roughly one session per GiB, including four sessions on the default 4 GiB boxes. PR #668 changed the implementation plan to a static default of four to avoid kernel memory reservations rounding a nominal 4 GiB box down to three. That made large boxes keep the four-session ceiling; this 62.6 GiB box still reported 4 instead of roughly 60.

What changed

  • Make an unset sessionLimit automatic and derive it from /proc/meminfo MemTotal.
  • Round up to the next GiB so nominal 4 GiB deployments still receive four slots; enforce a minimum of one.
  • Preserve an explicit positive-integer sessionLimit override.
  • Fail closed if the automatic RAM probe is malformed or unavailable.
  • Update CLI/help text, module/native renderers, generated output, and golden fixtures.
  • Add unit coverage for automatic boundaries, missing config, explicit override, and malformed inputs.

The default on the current 62.6 GiB host computes to 63 sessions.

User-visible and migration impact

Deployments without an explicit sessionLimit move from a fixed limit of 4 to approximately one slot per GiB of physical RAM. Deployments that intentionally rely on four can set sessionLimit = 4; existing explicit settings are unchanged. This remains admission control, not a per-session memory guarantee.

Security / infrastructure impact

No IAM, network, AWS resource, image-format, or direct cloud-cost changes. The larger automatic limit allows more local agent processes on larger hosts, proportional to their RAM. No data migration is required.

Validation

  • nix run .#assemble
  • nix run .#update-native-config
  • nix run .#update-golden
  • python3 tests/test-session-capacity.py — 16 passed
  • python3 tests/test_agentbox.py — 150 passed, 1 skipped
  • nix build -L --keep-going --max-jobs 4 --cores 1 --no-link .#ci-native
  • nix build -L --no-link .#checks.x86_64-linux.session-limit
  • git diff --check

Follow-up to #662 and #668.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: dcffd922-1ee7-4e52-a80a-729b9f970a56

📥 Commits

Reviewing files that changed from the base of the PR and between 0e85416 and 0289f46.

📒 Files selected for processing (25)
  • README.md
  • bin/agentbox
  • flake.nix
  • modules/agent-box.nix
  • modules/agent-box.nix.in
  • modules/src/default-agents-webhook.md
  • modules/src/default-agents.md
  • modules/src/lib/session-capacity.py
  • modules/src/session-cli.sh
  • modules/src/webhook-cli.sh
  • tests/golden/DUPLICATES
  • tests/golden/vm/etc/agent-box-guides/AGENTS.agent.md
  • tests/golden/vm/etc/agent-box/session-limit
  • tests/golden/vm/payloads/agent-box-session-capacity/bin/agent-box-session-capacity
  • tests/golden/vm/payloads/agent-box-session/bin/agent-box-session
  • tests/golden/web/etc/agent-box-guides/AGENTS.agent.md
  • tests/golden/web/payloads/agent-box-settings/bin/agent-box-settings
  • tests/golden/web/payloads/agent-box-webhook/bin/agent-box-webhook
  • tests/native/config.json
  • tests/native/config.yaml
  • tests/native/expected/etc/agent-box-guides/AGENTS.agent.md
  • tests/native/expected/etc/agent-box-guides/AGENTS.robot.md
  • tests/native/expected/etc/agent-box/session-limit
  • tests/test-session-capacity.py
  • tests/test_agentbox.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread modules/src/lib/session-capacity.py
@lionello
lionello merged commit 5825dc4 into master Sep 12, 2026
8 checks passed
@lionello
lionello deleted the fix/ram-derived-session-limit branch September 12, 2026 14:38
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Agent-Box Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants