Skip to content

feat(sandbox): stop generating client-side default names so unnamed creations can use warm pools (ENG-3931)#190

Merged
cploujoux merged 2 commits into
mainfrom
cploujoux/devin/eng-3931-no-client-default-sandbox-name
Jul 15, 2026
Merged

feat(sandbox): stop generating client-side default names so unnamed creations can use warm pools (ENG-3931)#190
cploujoux merged 2 commits into
mainfrom
cploujoux/devin/eng-3931-no-client-default-sandbox-name

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Warm sandbox pools (ENG-3889) only serve creations where metadata.name is absent. But SandboxInstance.create / SyncSandboxInstance.create generated a client-side default name (sandbox-<8 hex>) whenever the caller omitted one, so every unnamed SDK creation reached the API with a name and silently fell back to the slow classic path.

This drops the client-side default name. When the caller doesn't provide a name we now send the create request without metadata.name and let the server assign one; the server-assigned name is surfaced on the returned instance as before.

Because the generated Metadata.to_dict() always emits name, a small helper serializes the body and strips the key when unnamed:

def _create_body(sandbox: Sandbox) -> Union[Sandbox, Dict[str, Any]]:
    if sandbox.metadata and sandbox.metadata.name:
        return sandbox            # named → send the model as-is
    body = sandbox.to_dict()
    body["metadata"].pop("name", None)   # unnamed → omit metadata.name
    return body

create_sandbox's generated client already accepts a dict body, so no generated code changes. The same change is applied to both the async (default/) and sync (sync/) implementations.

Notes:

  • Explicitly named creations are unchanged.
  • create_if_not_exists still requires a name (unchanged) — it needs one for its existence check.

Test

Added unit tests in tests/core/test_sandbox.py (async + sync) asserting the create body omits metadata.name for unnamed / raw-model creations, keeps a caller-provided name, and surfaces the server-assigned name.

Same change made in the TypeScript SDK: blaxel-ai/sdk-typescript#(companion PR).

Link to Devin session: https://app.devin.ai/sessions/652893c91fb340faa3d0064943629994
Requested by: @cploujoux


Note

Removes client-side default name generation (sandbox-<hex>) from SandboxInstance.create and SyncSandboxInstance.create, so that unnamed sandbox creations reach the API without metadata.name and can be served by warm sandbox pools. A _create_body helper strips the name key from the serialized dict when no name was provided.

Written by Mendral for commit a764b9c.

…reations can use warm pools (ENG-3931)

Co-Authored-By: cploujoux <cploujoux@blaxel.ai>
@cploujoux cploujoux self-assigned this Jul 14, 2026
@cploujoux
cploujoux self-requested a review July 14, 2026 17:05
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@mendral-app

mendral-app Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

🧪 Testing Guide

What this PR addresses

The SDK was generating a client-side default name (sandbox-<8 hex>) whenever a caller created a sandbox without specifying a name. This caused every unnamed creation to hit the API with a metadata.name, making it ineligible for warm sandbox pools (which only serve requests where metadata.name is absent). This PR removes the client-side default so unnamed creations reach the API without a name, enabling the server to assign one and route the request through the warm pool path.

Steps to reproduce the original issue

  1. Call SandboxInstance.create({"image": "blaxel/base-image:latest"}) (or the sync equivalent) without providing a name field.
  2. Inspect the request body sent to the create_sandbox API (e.g., via mock or network trace).
  3. Before this PR: metadata.name is always present (e.g., "sandbox-a1b2c3d4"), so the request bypasses warm pools.
  4. After this PR: metadata.name is absent from the request body, allowing the server to assign a name and serve from a warm pool.

What to verify (expected behavior)

  • Unnamed creation (dict config): When creating a sandbox via dict without a name key, the body sent to the API must be a dict with metadata.name not present (not None, not empty — the key itself should be absent).
  • Named creation: When a name is explicitly provided (e.g., {"name": "mysbx", ...}), the body must include metadata.name == "mysbx" as before.
  • Raw Sandbox model without metadata: Passing Sandbox(metadata=None, spec=SandboxSpec()) should also result in no metadata.name in the request body.
  • Server-assigned name surfaced: The returned SandboxInstance should reflect the server-assigned name (from the API response), not a client-generated one.
  • Sync path: All the above behaviors should be identical for SyncSandboxInstance.create.
  • Existing tests pass: Run pytest tests/core/test_sandbox.py — the 6 new tests covering these scenarios should all pass, along with all pre-existing tests.

Note

Posted by PR Testing Guide · Tag @mendral-app with feedback.

@mendral-app

mendral-app Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

✅ Linked to Linear issue ENG-3931 — status: In Review

The PR is now attached to the issue and will auto-close it when merged.

Note

Posted by Linear Issue Enforcer · Tag @mendral-app with feedback.

mendral-app[bot]

This comment was marked as outdated.

…ENG-3931)

Co-Authored-By: cploujoux <cploujoux@blaxel.ai>
@cploujoux
cploujoux merged commit 2a2cfa3 into main Jul 15, 2026
16 of 21 checks passed
@cploujoux
cploujoux deleted the cploujoux/devin/eng-3931-no-client-default-sandbox-name branch July 15, 2026 22:46
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