Repository navigation
Support Python packages in the monorepo (DX-3182) #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
CahidArda
merged 6 commits into
main
from
dx-3182-agentkit-add-python-package-support-to-the-monorepo
Oct 28, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ca8f6d1
chore: support Python packages in the monorepo (DX-3182)
CahidArda c7da5fa
ci: run Python checks and publish Python packages to PyPI (DX-3182)
CahidArda 435b1f0
test(hermes-memory): check version carriers, wheel contents and the t…
CahidArda a12c48d
fix: finish a half-done Python release on rerun; load .env in Python …
CahidArda 1127ccc
fix: upload the files a partial PyPI release is missing (DX-3182)
CahidArda 86e2e85
Merge main into dx-3182 (resolve CLAUDE.md/README.md package table co…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,8 @@ coverage | |
| *.tsbuildinfo | ||
| .vscode | ||
| .idea | ||
| .venv | ||
| __pycache__ | ||
| *.egg-info | ||
| .pytest_cache | ||
| .ruff_cache | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| packages: | ||
| - "packages/*" | ||
| - "examples/*" | ||
| - "python/*" | ||
| allowBuilds: | ||
| esbuild: true | ||
| sharp: true | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # uv workspace for the Python packages under python/*. It lives beside the pnpm workspace rather than | ||
| # replacing anything: each Python package also carries a private package.json so Changesets versions | ||
| # it like every other package (see the "Python packages" section of CLAUDE.md). | ||
| [tool.uv.workspace] | ||
| members = ["python/*"] | ||
|
|
||
| [dependency-groups] | ||
| dev = ["pytest>=8", "ruff>=0.6"] | ||
|
|
||
| [tool.ruff] | ||
| line-length = 100 | ||
| target-version = "py311" | ||
|
|
||
| [tool.pytest.ini_options] | ||
| testpaths = ["python"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # upstash-hermes-memory | ||
|
|
||
| An Upstash Redis memory provider for [Hermes Agent](https://hermes-agent.nousresearch.com), built on | ||
| the same Redis Search layout as `@upstash/agentkit-sdk`'s `AgentMemory` and `ChatHistory`. | ||
|
|
||
| **Status: scaffold.** The package is at `0.0.0`, which `scripts/publish-python.mjs` treats as | ||
| unreleased, so nothing is published to PyPI yet. The provider itself is tracked in DX-3182. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "upstash-hermes-memory", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "description": "Version carrier for the upstash-hermes-memory PyPI package. Changesets bumps it; scripts/sync-version.mjs copies it into pyproject.toml." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| [project] | ||
| name = "upstash-hermes-memory" | ||
| version = "0.0.0" | ||
| description = "Upstash Redis memory provider for Hermes Agent: long-term memory, searchable chat history and recall on Redis Search, with no separate vector database." | ||
| readme = "README.md" | ||
| license = "MIT" | ||
| requires-python = ">=3.11" | ||
| dependencies = ["upstash-redis>=1.8.0"] | ||
|
|
||
| [project.urls] | ||
| Homepage = "https://github.com/upstash/agentkit" | ||
| Repository = "https://github.com/upstash/agentkit" | ||
|
|
||
| [build-system] | ||
| requires = ["hatchling"] | ||
| build-backend = "hatchling.build" |
12 changes: 12 additions & 0 deletions
12
python/hermes-memory/src/upstash_hermes_memory/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| """Upstash Redis memory provider for Hermes Agent. | ||
|
|
||
| Hermes stopped taking new memory providers in its own repository: they ship as standalone plugins | ||
| and are listed in its plugin catalog. This package is that plugin, and it lives in the AgentKit | ||
| monorepo rather than in a repository of its own so the Python port reads and writes exactly the | ||
| keys and Redis Search indexes the TypeScript SDK does. A memory saved from an AI SDK app is then | ||
| recalled by a Hermes agent on the same database. | ||
| """ | ||
|
|
||
| from ._version import VERSION | ||
|
|
||
| __all__ = ["VERSION"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Generated by scripts/sync-version.mjs (run by `pnpm ci:version`) — do not edit by hand. | ||
| VERSION = "0.0.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import os | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| REPO_ROOT = Path(__file__).parents[3] | ||
|
|
||
|
|
||
| def _load_root_env() -> None: | ||
| """Load the repo-root `.env` like the TS tests do (dotenv in test-support.ts). | ||
|
|
||
| Variables already in the environment win, so CI's secrets are never overridden. Without the | ||
| file and without the variables, the Redis tests skip themselves as before. | ||
| """ | ||
| path = REPO_ROOT / ".env" | ||
| if not path.is_file(): | ||
| return | ||
| for line in path.read_text().splitlines(): | ||
| line = line.strip() | ||
| if not line or line.startswith("#") or "=" not in line: | ||
| continue | ||
| key, value = line.split("=", 1) | ||
| key, value = key.strip().removeprefix("export ").strip(), value.strip() | ||
| if len(value) >= 2 and value[0] == value[-1] and value[0] in "\"'": | ||
| value = value[1:-1] | ||
| os.environ.setdefault(key, value) | ||
|
|
||
|
|
||
| _load_root_env() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def redis(): | ||
| """A client for the shared test Redis, or a skip when CI has no secrets (fork PRs).""" | ||
| if not ( | ||
| os.environ.get("UPSTASH_REDIS_REST_URL") and os.environ.get("UPSTASH_REDIS_REST_TOKEN") | ||
| ): | ||
| pytest.skip("UPSTASH_REDIS_REST_URL / UPSTASH_REDIS_REST_TOKEN not set") | ||
| from upstash_redis import Redis | ||
|
|
||
| return Redis.from_env() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import shutil | ||
| import subprocess | ||
| import zipfile | ||
| from email.parser import Parser | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
| import upstash_hermes_memory | ||
| from upstash_hermes_memory import VERSION | ||
|
|
||
| REPO_ROOT = Path(__file__).parents[3] | ||
|
|
||
|
|
||
| def test_public_api(): | ||
| assert upstash_hermes_memory.__all__ == ["VERSION"] | ||
| assert isinstance(VERSION, str) | ||
|
|
||
|
|
||
| @pytest.mark.skipif(shutil.which("uv") is None, reason="uv not on PATH") | ||
| def test_wheel_contents(tmp_path): | ||
| # What publish-python.mjs uploads: build the wheel the same way and check what is inside it. | ||
| subprocess.run( | ||
| ["uv", "build", "--wheel", "--package", "upstash-hermes-memory", "--out-dir", tmp_path], | ||
| cwd=REPO_ROOT, | ||
| check=True, | ||
| capture_output=True, | ||
| ) | ||
| (wheel,) = tmp_path.glob("*.whl") | ||
| assert wheel.name.startswith(f"upstash_hermes_memory-{VERSION}-") | ||
|
|
||
| with zipfile.ZipFile(wheel) as zf: | ||
| names = zf.namelist() | ||
| assert "upstash_hermes_memory/__init__.py" in names | ||
| assert "upstash_hermes_memory/_version.py" in names | ||
| # Tests and the private package.json are repo plumbing, not part of the distribution. | ||
| assert not any(n.startswith("tests/") or n.endswith("package.json") for n in names) | ||
| metadata = Parser().parsestr( | ||
| zf.read(f"upstash_hermes_memory-{VERSION}.dist-info/METADATA").decode() | ||
| ) | ||
|
|
||
| assert metadata["Name"] == "upstash-hermes-memory" | ||
| assert metadata["Version"] == VERSION | ||
| assert metadata["Requires-Python"] == ">=3.11" | ||
| assert any(r.startswith("upstash-redis") for r in metadata.get_all("Requires-Dist")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import uuid | ||
|
|
||
|
|
||
| def test_round_trip(redis): | ||
| # Smoke test for the CI wiring: the pinned client reaches the shared test database. It uses a | ||
| # plain key with a TTL, never a search index, so it does not count against the 10-index cap. | ||
| key = f"agentkit-test:python:{uuid.uuid4().hex}" | ||
| try: | ||
| assert redis.set(key, "hermes", ex=60) | ||
| assert redis.get(key) == "hermes" | ||
| finally: | ||
| redis.delete(key) | ||
| assert redis.get(key) is None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import json | ||
| import re | ||
| import tomllib | ||
| from importlib.metadata import version | ||
| from pathlib import Path | ||
|
|
||
| from upstash_hermes_memory import VERSION | ||
|
|
||
| PACKAGE_DIR = Path(__file__).parents[1] | ||
|
|
||
|
|
||
| def test_version_matches_pyproject(): | ||
| # The telemetry constant and the published version must agree; sync-version.mjs keeps them so. | ||
| pyproject = tomllib.loads((PACKAGE_DIR / "pyproject.toml").read_text()) | ||
| assert VERSION == pyproject["project"]["version"] | ||
|
|
||
|
|
||
| def test_version_matches_package_json(): | ||
| # Changesets bumps the private package.json; that is the source the other two are copied from. | ||
| package_json = json.loads((PACKAGE_DIR / "package.json").read_text()) | ||
| assert VERSION == package_json["version"] | ||
|
|
||
|
|
||
| def test_package_json_names_the_distribution(): | ||
| # sync-version.mjs derives the module path from this name, and publish-python.mjs queries PyPI | ||
| # with it, so it has to be the PyPI project name exactly. | ||
| package_json = json.loads((PACKAGE_DIR / "package.json").read_text()) | ||
| pyproject = tomllib.loads((PACKAGE_DIR / "pyproject.toml").read_text()) | ||
| assert package_json["name"] == pyproject["project"]["name"] | ||
| assert package_json["private"] is True | ||
|
|
||
|
|
||
| def test_version_is_plain_semver(): | ||
| # Changesets writes semver; anything else would not round-trip through PEP 440 unchanged. | ||
| assert re.fullmatch(r"\d+\.\d+\.\d+(-[0-9A-Za-z.]+)?", VERSION) | ||
|
|
||
|
|
||
| def test_installed_metadata_matches(): | ||
| # Catches a stale `uv sync`: the environment must carry the version the source declares. | ||
| assert version("upstash-hermes-memory") == VERSION |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.