Repository navigation
feat(sandbox): start a sandbox using an Agent Profile's Sandbox Spec - #1601
Conversation
POST /api/v1/sandboxes accepts agent_profile_id. The profile resolves as a conversation launch in the caller's organization would; its sandbox spec wins over saved defaults, a profile without one gets the org default and then the deployment's, and an unavailable spec is a 422 before any allocation. The response echoes agent_profile_id so clients can tell the parameter was applied. Co-authored-by: openhands <openhands@all-hands.dev>
Address the PRD-197 review. The profile start moves from a query parameter on POST /api/v1/sandboxes to POST /api/v1/sandboxes/start-with-agent-profile, so an app server without it answers 404/405 before allocating anything. POST /api/v1/sandboxes is back to its released shape. Every launch refusal of the profile keeps its own structured code. Adds database-backed tests through the real settings store, flag, org binding and spec access, including personal profiles and a service account. Co-authored-by: openhands <openhands@all-hands.dev>
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||
Review posted for
|
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
The new POST /api/v1/sandboxes/start-with-agent-profile route looks correct. It applies the same licence check as POST '', resolves the profile through the existing override_agent_profile_id path, and rejects an unlaunchable profile or an inaccessible spec with a 422 before start_sandbox runs. It returns the plain-route behavior with a null profile when Agent Profiles are off. The service-account allowlist entry is present. All GitHub checks on this head pass.
I could not run the focused tests in this workspace, because the repo conftest.py needs a Docker daemon. I relied on the passing CI shards and read the tests instead.
One non-blocking point is on the inline comment: a profile with no spec skips the owner's saved default spec.
✅ APPROVED
LLM profile: unknown · Model: openhands/claude-sonnet-5-5
| return StartedSandboxInfo(**info.model_dump(), agent_profile_id=None) | ||
| spec_id = user.active_agent_profile_sandbox_spec_id | ||
| if spec_id is None: | ||
| spec_id = (await sandbox_spec_service.get_default_sandbox_spec()).id |
There was a problem hiding this comment.
Non-blocking: when the profile names no spec, this passes the organization default as an explicit sandbox_spec_id. resolve_sandbox_spec ranks an explicit id above the owner's saved default_sandbox_spec_id, so that saved default is skipped here. It is honored by POST '' and by the sandbox a conversation start creates. test_profile_without_spec_uses_org_then_deployment_default pins this: the fixture's owner default is spec-personal and the result is the org default.
A profile with no spec expresses no spec preference. An owner who has a personal default and runs an automation with a spec-less profile will move from the personal default to the org default once Automation starts sending the profile. If that is not intended, call sandbox_service.start_sandbox() in this case, so the usual precedence applies, and keep the explicit id only when the profile has a spec. If it is intended, a note about this case in the PR description would help operators.
SaaS impact assessmentVerdict: The PR adds one route and changes no existing route. It works at the config each environment runs. Nothing breaks until Automation calls the route. There is no opt-out.
Validation: The diff and call sites are static. Each Automation service calls the Enterprise server of its own environment (deploy values). The Agent Profiles flag per environment is not verified. I verified nothing live. Rollout: No release includes the PR yet. The Enterprise image and the Automation image roll out on separate pins. Roll out Enterprise first. To undo the change, revert the image. The change has no migration. Changed symbols and call sites
This analysis was produced by an AI agent (OpenHands) on behalf of @aivong-openhands. |
|
Note This PR adds a route and breaks nothing. Complete the Enterprise rollout before you deploy the Automation change. OHE impact assessmentVerdict: The PR adds
Validation: The diff and call sites are static (PR head, open PR). The chart pairing of Enterprise and Automation versions is not verified. I verified nothing live. The PR author reports stubbed runtime allocation. Customer installs:
Rollout: The route reaches an install on the next image rollout. To undo it, revert the image. The change has no migration. Deploy the Automation change only after every Enterprise instance runs this route. Changed symbols and call sites
This analysis was produced by an AI agent (OpenHands) on behalf of @aivong-openhands. |
|
I tested this PR on a live install. The cluster is a fresh Replicated Embedded Cluster install that runs the PR's image, pr1601-start-with-agent-profile.webmSetup: the deployment has two Sandbox Specs, The video (80 seconds) shows these calls:
The sandbox that the profile started reaches Notes:
|
|
🚀 Released in 1.104.0. |
HUMAN:
AGENT:
This draft was prepared with AI assistance.
Why
A run can select an Agent Profile, but Automation creates its sandbox before starting the conversation. The sandbox start previously used the owner's default spec even when the selected profile specified a different one.
How the two changes work together
Say the selected Agent Profile calls for an 8 GB sandbox and the usual sandbox has 4 GB.
The compatibility cutoff is deployment of the Enterprise PR. Complete that rollout across all Enterprise instances before deploying the Automation PR. Merging the Enterprise PR alone does not add the endpoint to running servers.
Summary
POST /api/v1/sandboxes/start-with-agent-profile. It resolves the selected profile in the caller's organization and passes the validated spec to the existing sandbox service.openhands/app_server/sandbox/sandbox_router.py.Issue Number
PRD-197
How to Test
The final commit passed 260 focused tests on EKS, including database-backed profile and spec access, quota, and route classification. The previous router returned 405 for the new endpoint without invoking sandbox creation. Fable 5.2 reviewed this exact commit and reported no actionable issues. The tests exercise spec resolution with the runtime allocation backend stubbed. Live validation remains pending.
Video/Screenshots
Both requests ran against the same database-backed Enterprise fixture on EKS. The original request omitted the profile and returned the organization default,
spec-org. The new request included profilesmalland returned its spec,spec-private-2g. Runtime allocation was stubbed.Type
Notes
Complete the Enterprise rollout before deploying the companion Automation change. Custom and script runs with an unlaunchable selected profile fail before allocation. A profile edit between sandbox and conversation start can leave the sandbox on the spec chosen at allocation.
Enterprise server image for this PR: