Tags and versions
A tag points to a specific build. A complete reference uses name:tag, for example python-tools:v1 or python-tools:production.
Pass one or more tags to Template.build. You can then assign and remove tags without rebuilding the template.
mjs
import { Sandbox, Template } from "@abox-dev/sdk";
const templateName = process.env.TEMPLATE_NAME ?? "versioned-template";
const template = Template().fromBaseImage().runCmd("echo versioned");
await Template.build(template, templateName, {
tags: ["v1", "stable"],
});
await Template.assignTags(`${templateName}:v1`, "production");
await Template.removeTags(templateName, "stable");
const tags = await Template.getTags(templateName);
console.log(
tags
.map(({ tag }) => tag)
.sort()
.join(", "),
);
const sandbox = await Sandbox.create(`${templateName}:production`);
try {
console.log(`Started ${sandbox.sandboxId}`);
} finally {
await sandbox.kill();
}py
import os
from agentbox import Sandbox, Template
template_name = os.getenv("TEMPLATE_NAME", "versioned-template")
template = Template().from_base_image().run_cmd("echo versioned")
Template.build(template, template_name, tags=["v1", "stable"])
Template.assign_tags(f"{template_name}:v1", "production")
Template.remove_tags(template_name, "stable")
tags = Template.get_tags(template_name)
print(", ".join(sorted(tag.tag for tag in tags)))
sandbox = Sandbox.create(f"{template_name}:production")
try:
print(f"Started {sandbox.sandbox_id}")
finally:
sandbox.kill()assignTags or assign_tags moves a new tag to the selected build. removeTags or remove_tags removes only that pointer; other tags for the build keep working. getTags or get_tags returns the tag, build ID, and assignment time.
Use tags such as v1.4.0 for immutable releases and staging or production for promotion. Starting a sandbox from an explicit tag makes the selected version clear.