Skip to content

fix(modal): reuse env secrets across sandbox operations#1805

Closed
EazyReal wants to merge 1 commit into
harbor-framework:mainfrom
VmaxAI:codex/modal-secret-cache
Closed

fix(modal): reuse env secrets across sandbox operations#1805
EazyReal wants to merge 1 commit into
harbor-framework:mainfrom
VmaxAI:codex/modal-secret-cache

Conversation

@EazyReal

@EazyReal EazyReal commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Problem

The Modal environment injects persistent task env and per-exec env through Secret.from_dict. Under high concurrency, identical env payloads can produce one ephemeral Modal Secret per sandbox startup and per exec. Modal applies workspace-wide secret create limits, so a startup or setup burst can fail with transient infrastructure errors even though the env payload is unchanged.

Approach

  • Cache Secret.from_dict objects by an order-independent env payload key.
  • Reuse that cached env secret for both sandbox creation (_secrets_config) and per-command execution (_sdk_exec).
  • Keep named Modal secrets unchanged.
  • Increase sandbox creation retries from 2 to 4 attempts with a slightly longer exponential backoff cap for residual transient provider spikes.
  • Add regression coverage for same-payload reuse, distinct-payload separation, persistent sandbox env injection, and per-exec env injection.

Validation

  • uv run pytest tests/unit/environments/test_modal.py -q -> 28 passed
  • uv run ruff check --fix . -> All checks passed!
  • uv run ruff format . -> 1004 files left unchanged
  • uv run ty check -> All checks passed!
  • uv run pytest tests/unit -q -> 2723 passed, 1 skipped

@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

@EazyReal is attempting to deploy a commit to the Harbor Framework Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Enjoy a better diff viewing experience by clicking one of these URLs:

@EazyReal EazyReal closed this Jun 2, 2026
@EazyReal EazyReal deleted the codex/modal-secret-cache branch June 2, 2026 21:18

EazyReal commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1806 so the source branch can use modal-secret-cache instead of codex/modal-secret-cache.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant