Skip to content

Commit 46bd6ef

Browse files
fix(packaging): guard against missing/skewed agentex-client at ADK import
The 0.13.0 split shipped agentex-sdk and agentex-client as two distributions sharing the agentex.* namespace, coupled only by a floor pin. A partial or version-skewed install left agentex/lib/* present but the client surface (agentex/types, agentex/resources) missing, crashing ADK startup with a cryptic `cannot import name 'Event' from 'agentex.types'`. - Verify the client surface at agentex.lib import time and raise an actionable ImportError naming both installed versions when it is absent. - Bump the agentex-client floor to >=0.13.0 (the first release where it ships separately) so an old client cannot satisfy the dep. Kept floor-only: a ceiling would exclude the co-versioned slim (release-please cannot bump it). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 23858df commit 46bd6ef

4 files changed

Lines changed: 56 additions & 1 deletion

File tree

adk/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ readme = "README.md"
1515
dependencies = [
1616
# Co-released in lockstep; floor-only by design — a ceiling would
1717
# eventually exclude the co-versioned slim (release-please can't bump it).
18-
"agentex-client>=0.12.0",
18+
"agentex-client>=0.13.0",
1919
# CLI surface (agentex.lib.cli.*, agentex.lib.sdk.config.*)
2020
"typer>=0.16,<0.17",
2121
"questionary>=2.0.1,<3",

src/agentex/lib/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from agentex.lib._version_guard import verify_agentex_client_available
2+
3+
# Validate the agentex-client sibling at ADK import time so a partial/skewed
4+
# install fails with an actionable message, not a cryptic ImportError.
5+
verify_agentex_client_available()

src/agentex/lib/_version_guard.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Guard that the agentex-client REST surface (shared agentex.* namespace) is
2+
importable; raise an actionable error instead of a cryptic ImportError."""
3+
4+
from __future__ import annotations
5+
6+
from importlib.metadata import PackageNotFoundError, version
7+
8+
9+
def _version_or_missing(package: str) -> str:
10+
try:
11+
return version(package)
12+
except PackageNotFoundError:
13+
return "not installed"
14+
15+
16+
def verify_agentex_client_available() -> None:
17+
# `Event` is the canary symbol whose absence crashed ADK startup in 0.13.0.
18+
try:
19+
from agentex.types import Event as _Event # noqa: F401
20+
except (ImportError, AttributeError) as exc:
21+
raise ImportError(
22+
"agentex-sdk could not import the agentex-client REST surface it "
23+
"depends on (the two ship as one `agentex.*` namespace and must be "
24+
"installed together at the same version). Installed: "
25+
f"agentex-sdk={_version_or_missing('agentex-sdk')}, "
26+
f"agentex-client={_version_or_missing('agentex-client')}. "
27+
"Reinstall both, e.g. `pip install --force-reinstall agentex-sdk`."
28+
) from exc

tests/lib/test_version_guard.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""Tests for the agentex-client availability guard (0.13.0 split regression)."""
2+
3+
from __future__ import annotations
4+
5+
import pytest
6+
7+
from agentex.lib._version_guard import verify_agentex_client_available
8+
9+
10+
def test_passes_when_client_surface_present() -> None:
11+
verify_agentex_client_available() # both packages installed -> no raise
12+
13+
14+
def test_raises_clear_error_when_client_surface_broken(
15+
monkeypatch: pytest.MonkeyPatch,
16+
) -> None:
17+
import agentex.types
18+
19+
# Simulate a skewed/partial agentex-client where the canary symbol is absent.
20+
monkeypatch.delattr(agentex.types, "Event", raising=False)
21+
with pytest.raises(ImportError, match="agentex-client"):
22+
verify_agentex_client_available()

0 commit comments

Comments
 (0)