mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[GH-ISSUE #9] Support direct OCI image in sandbox creation API #4
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yingdi-shan on GitHub (Jul 27, 2026).
Original GitHub issue: https://github.com/kvcache-ai/AgentENV/issues/9
Current Limitation
The sandbox creation API currently requires users to pre-create a template before creating sandboxes. This adds friction to the common workflow of "I have an OCI image, I want to run a sandbox from it."
Meanwhile, the cold creation path already supports OCI images directly, demonstrating that the underlying infrastructure can handle this use case.
Proposed Enhancement
Add a new endpoint to accept an OCI image reference directly:
When an OCI image is provided, the API should:
This would preserve the internal architecture (templates remain the source of truth for sandbox state) while simplifying the external API surface.
Benefits
User Experience
API Ergonomics
Backwards Compatibility
Template Naming Strategy
Auto-generated templates should use template_name (not template_id, which remains a UUID) following the pattern:
Example:
a1b2c3d4e5f6-2c-2048mb-10gbPreventing Name Collisions
To prevent users from creating templates with names that collide with auto-generated ones (even before the auto-generated template exists), the template creation API must validate and reject user-provided names matching the auto-generation pattern.
Image Digest Extraction
When the user provides an OCI image reference (e.g.,
ghcr.io/org/image:tag):regctl manifest get --digest <image>sha256:abc123...def456)IMAGE_DIGESTWhy Manifest Digest?
image:latestmultiple times with unchanged content reuses the cached templateTemplate Reuse Logic
Two users requesting the same image with different resource specs will generate different template names due to the CPU/MEM/DISK suffix. If the same user requests the same image+specs twice:
a1b2c3d4e5f6-2c-2048mb-10gb, then sandboxSince user-created templates cannot use the auto-generation naming pattern (rejected at creation time), name collisions between user templates and auto-generated templates are impossible.
Implementation Considerations
Request Schema
Response Schema
Include both sandbox and template information:
Template Lifecycle
Persistence: Auto-created templates should be persisted with a special marker (e.g.,
auto_generated: truein metadata) to enable:Tagging: Add internal metadata to distinguish auto-created templates:
Error Handling
Image pull failures: Return clear errors (not template-not-found)
400 Bad Request: Invalid image reference format404 Not Found: Image not found in registry401 Unauthorized: Registry authentication required500 Internal Server Error: Image resolution failedTemplate creation failures: Roll back and return error (no orphaned templates)
Large images: Consider async creation with status polling for images >1GB
202 Acceptedwith polling endpointRate Limiting
Observability
Metrics:
agentenv_auto_template_create_total{status="success|failure"}agentenv_auto_template_reuse_totalagentenv_sandbox_from_image_duration_secondsLogs:
auto_generated=truefieldAdmin API:
auto_generatedflagRelated
POST /v3/templatesPOST /v3/sandboxes