Skip to content

Agent Zero AI framework

Simplify version tag format from vX.Y.Z to vX.Y, enforce v1.0 minimum

frdelded0f480c817
diff --git a/docs/guides/self-update.md b/docs/guides/self-update.md
index 40aaa1159..8a342f3d2 100644
--- a/docs/guides/self-update.md
+++ b/docs/guides/self-update.md
@@ -37,18 +37,20 @@ The WebUI fetches repository version tags for the selected branch and lets you e
Agent Zero version tags follow this format:
-`v{epoch}.{major}.{minor}.{rest}`
+`v{major}.{minor}`
Examples:
-- `v0.9.9.2`
-- `v1.0.3.0`
+- `v1.0`
+- `v1.1`
+
+Tags below `v1.0` are ignored by the selector and rejected by the self-update request validator.
## Major version limitation
-Self-update is intentionally limited to changes within the same `epoch.major` line.
+Self-update is intentionally limited to changes within the same major line.
-If the requested version changes the `epoch` or `major` part of the version, the UI blocks the update and shows a warning. Those upgrades require downloading a new Docker image because they can include operating system level changes or other breaking changes outside the repository checkout.
+If the requested version changes the first version number, the UI blocks the update and shows a warning. Those upgrades require downloading a new Docker image because they can include operating system level changes or other breaking changes outside the repository checkout.
## Safety notes
diff --git a/helpers/self_update.py b/helpers/self_update.py
index 50ca1355d..95d197ac1 100644
--- a/helpers/self_update.py
+++ b/helpers/self_update.py
@@ -19,7 +19,7 @@ BRANCH_OPTIONS = [
]
SUPPORTED_BRANCHES = {option["value"] for option in BRANCH_OPTIONS}
BACKUP_CONFLICT_POLICIES = {"rename", "overwrite", "fail"}
-MIN_SELECTOR_VERSION = (0, 9, 9)
+MIN_SELECTOR_VERSION = (1, 0)
UPDATE_FILE_PATH = Path("/exe/a0-self-update.yaml")
STATUS_FILE_PATH = Path("/exe/a0-self-update-status.yaml")
@@ -207,14 +207,13 @@ def _get_branch_merged_tags(
return set()
-def _parse_selector_version(tag: str) -> tuple[int, int, int] | None:
- match = re.fullmatch(r"v(\d+)\.(\d+)\.(\d+)(?:\..+)?", tag.strip())
+def _parse_selector_version(tag: str) -> tuple[int, int] | None:
+ match = re.fullmatch(r"v(\d+)\.(\d+)", tag.strip())
if not match:
return None
return (
int(match.group(1)),
int(match.group(2)),
- int(match.group(3)),
)
@@ -227,6 +226,10 @@ def _filter_selector_supported_tags(tags: list[str]) -> list[str]:
return [tag for tag in tags if _is_selector_supported_tag(tag)]
+def _sort_selector_supported_tags(tags: list[str]) -> list[str]:
+ return sorted(tags, key=lambda tag: _parse_selector_version(tag) or (-1, -1), reverse=True)
+
+
def is_valid_selector_tag(tag: str) -> bool:
return _parse_selector_version(tag) is not None
@@ -247,7 +250,7 @@ def get_available_tags(
if merged_tags:
tags = [tag for tag in tags if tag in merged_tags]
- tags = _filter_selector_supported_tags(tags)
+ tags = _sort_selector_supported_tags(_filter_selector_supported_tags(tags))
normalized_query = query.strip().lower()
if normalized_query:
@@ -278,7 +281,7 @@ def get_update_info(repo_dir: str | Path | None = None) -> dict[str, Any]:
},
"defaults": {
"branch": default_branch,
- "tag": current_version,
+ "tag": current_version if _is_selector_supported_tag(current_version) else "",
"backup_usr": True,
"backup_path": str(get_default_backup_dir(repository)),
"backup_name": build_default_backup_name(current_version, current_version),
@@ -308,9 +311,9 @@ def schedule_update(
if not normalized_tag:
raise ValueError("A release tag is required.")
if not is_valid_selector_tag(normalized_tag):
- raise ValueError(
- "Release tag must use the format vX.Y.Z with optional extra segments such as .W or .W-suffix."
- )
+ raise ValueError("Release tag must use the format vX.Y.")
+ if not _is_selector_supported_tag(normalized_tag):
+ raise ValueError("Release tag must be v1.0 or newer.")
normalized_policy = backup_conflict_policy.strip().lower()
if normalized_policy not in BACKUP_CONFLICT_POLICIES:
diff --git a/tests/test_self_update_tag_filter.py b/tests/test_self_update_tag_filter.py
index 54540af5b..703fbe1cb 100644
--- a/tests/test_self_update_tag_filter.py
+++ b/tests/test_self_update_tag_filter.py
@@ -12,15 +12,26 @@ sys.modules["giturlparse"] = types.SimpleNamespace(parse=lambda *args, **kwargs:
from helpers import self_update
-def test_self_update_minimum_selector_tag_is_enforced():
- assert self_update.is_valid_selector_tag("v0.9.9")
- assert self_update._is_selector_supported_tag("v0.9.9.0")
- assert self_update._is_selector_supported_tag("v0.10.0.0")
- assert self_update.is_valid_selector_tag("v0.9.12.5-pre")
- assert not self_update.is_valid_selector_tag("0.9.9")
- assert not self_update.is_valid_selector_tag("v0.9")
- assert not self_update._is_selector_supported_tag("v0.9.8.9")
- assert not self_update._is_selector_supported_tag("v0.7.0.0")
+def test_self_update_selector_tags_use_two_segments_and_v1_floor():
+ assert self_update.is_valid_selector_tag("v1.0")
+ assert self_update.is_valid_selector_tag("v12.34")
+ assert self_update.is_valid_selector_tag("v0.9")
+ assert self_update._is_selector_supported_tag("v1.0")
+ assert self_update._is_selector_supported_tag("v2.3")
+ assert not self_update.is_valid_selector_tag("1.0")
+ assert not self_update.is_valid_selector_tag("v1")
+ assert not self_update.is_valid_selector_tag("v1.0.0")
+ assert not self_update.is_valid_selector_tag("v1.0.0.1")
+ assert not self_update._is_selector_supported_tag("v0.9")
+ assert not self_update._is_selector_supported_tag("v0.99")
+
+
+def test_self_update_selector_tags_are_sorted_numerically():
+ assert self_update._sort_selector_supported_tags(["v1.9", "v2.0", "v1.10"]) == [
+ "v2.0",
+ "v1.10",
+ "v1.9",
+ ]
def test_self_update_frontend_filters_old_tag_suggestions():
@@ -34,6 +45,7 @@ def test_self_update_frontend_filters_old_tag_suggestions():
)
content = store_path.read_text(encoding="utf-8")
- assert "const MIN_SELECTOR_VERSION = [0, 9, 9];" in content
+ assert "const MIN_SELECTOR_VERSION = [1, 0];" in content
assert "response.tags.filter((tag) => this.isSupportedSuggestionTag(tag))" in content
- assert "if (!this.parseSelectorTag(this.form.tag)) {" in content
+ assert "Release tag must use the format vX.Y." in content
+ assert "Release tag must be v1.0 or newer." in content
diff --git a/webui/components/settings/external/self-update-modal.html b/webui/components/settings/external/self-update-modal.html
index 467d87db1..f265f3d47 100644
--- a/webui/components/settings/external/self-update-modal.html
+++ b/webui/components/settings/external/self-update-modal.html
@@ -127,7 +127,7 @@
<div class="field-description">
Enter a version tag from the
<a href="https://github.com/agent0ai/agent-zero" target="_blank" rel="noreferrer">Agent Zero repository</a>.
- Start typing to filter, or use the search button to fetch versions from the selected branch. Exact text entry is still allowed, including downgrades.
+ Start typing to filter, or use the search button to fetch versions from the selected branch. Only <code>vX.Y</code> tags at <code>v1.0</code> or newer are supported. Exact text entry is still allowed, including downgrades.
</div>
<template x-if="$store.selfUpdateStore.tagsError">
<div class="field-description">
@@ -143,7 +143,7 @@
@input="$store.selfUpdateStore.onTagInput()"
@focus="$store.selfUpdateStore.openTagDropdown()"
@keydown.enter.prevent="$store.selfUpdateStore.searchTags()"
- placeholder="v0.9.0"
+ placeholder="v1.0"
:disabled="$store.selfUpdateStore.isBusy"
style="padding-right: 32px;"
/>
diff --git a/webui/components/settings/external/self-update-store.js b/webui/components/settings/external/self-update-store.js
index 50b1c9301..f15272333 100644
--- a/webui/components/settings/external/self-update-store.js
+++ b/webui/components/settings/external/self-update-store.js
@@ -6,7 +6,7 @@ const HEALTH_POLL_INTERVAL_MS = 2000;
const HEALTH_WAIT_BUFFER_MS = 30000;
const SELF_UPDATE_RETURN_URL_KEY = "a0:self-update:return-url";
const SELF_UPDATE_OVERLAY_ID = "self-update-progress-overlay";
-const MIN_SELECTOR_VERSION = [0, 9, 9];
+const MIN_SELECTOR_VERSION = [1, 0];
const model = {
loading: false,
@@ -67,12 +67,12 @@ const model = {
},
get versionCompatibilityWarning() {
- const current = this.parseVersionTag(this.currentVersion);
- const target = this.parseVersionTag(this.form.tag);
+ const current = this.parseCompatibilityTag(this.currentVersion);
+ const target = this.parseCompatibilityTag(this.form.tag);
if (!current || !target) return "";
- if (current.epoch !== target.epoch || current.major !== target.major) {
+ if (current.major !== target.major) {
return (
- "Updating across major versions requires downloading a new Docker image, " +
+ "Changing the first version number requires downloading a new Docker image, " +
"because those releases can include operating system level changes or other breaking changes."
);
}
@@ -80,7 +80,12 @@ const model = {
},
get canScheduleUpdate() {
- return this.isSupported && !this.isBusy && !this.versionCompatibilityWarning;
+ return (
+ this.isSupported &&
+ !this.isBusy &&
+ this.isSupportedSelectorTag(this.form.tag) &&
+ !this.versionCompatibilityWarning
+ );
},
async init() {
@@ -274,7 +279,8 @@ const model = {
applyFormState(source) {
this.form.branch = source?.branch || "main";
- this.form.tag = source?.tag || this.currentVersion;
+ this.form.tag =
+ typeof source?.tag === "string" ? source.tag : this.currentVersion;
this.form.backup_usr =
typeof source?.backup_usr === "boolean" ? source.backup_usr : true;
this.form.backup_path = source?.backup_path || "";
@@ -342,16 +348,19 @@ const model = {
},
parseSelectorTag(value) {
- const match = /^v(\d+)\.(\d+)\.(\d+)(?:\..+)?$/.exec((value || "").trim());
+ const match = /^v(\d+)\.(\d+)$/.exec((value || "").trim());
if (!match) return null;
return [
Number.parseInt(match[1], 10),
Number.parseInt(match[2], 10),
- Number.parseInt(match[3], 10),
];
},
isSupportedSuggestionTag(value) {
+ return this.isSupportedSelectorTag(value);
+ },
+
+ isSupportedSelectorTag(value) {
const parsed = this.parseSelectorTag(value);
if (!parsed) return false;
for (let i = 0; i < MIN_SELECTOR_VERSION.length; i += 1) {
@@ -361,14 +370,12 @@ const model = {
return true;
},
- parseVersionTag(value) {
- const match = /^v(\d+)\.(\d+)\.(\d+)(?:\.(.+))?$/.exec((value || "").trim());
+ parseCompatibilityTag(value) {
+ const match = /^v(\d+)\.(\d+)(?:\..+)?$/.exec((value || "").trim());
if (!match) return null;
return {
- epoch: Number.parseInt(match[1], 10),
- major: Number.parseInt(match[2], 10),
- minor: Number.parseInt(match[3], 10),
- rest: match[4] || "",
+ major: Number.parseInt(match[1], 10),
+ minor: Number.parseInt(match[2], 10),
};
},
@@ -384,8 +391,12 @@ const model = {
}
if (!this.parseSelectorTag(this.form.tag)) {
- this.error =
- "Release tag must use the format vX.Y.Z with optional extra segments such as .W or .W-suffix.";
+ this.error = "Release tag must use the format vX.Y.";
+ return;
+ }
+
+ if (!this.isSupportedSelectorTag(this.form.tag)) {
+ this.error = "Release tag must be v1.0 or newer.";
return;
}