Skip to content

The agent that grows with you

fix(bundle): seed shipped venv state

Yuan Lib16c598c5dbd
diff --git a/scripts/bundles/native.py b/scripts/bundles/native.py
index 7636c615417..acbf722dd08 100644
--- a/scripts/bundles/native.py
+++ b/scripts/bundles/native.py
@@ -234,6 +234,13 @@ def _prepare_native(*, out: Path, ref: str, source: Path, cache: Path,
features = installed_extras(repo_dir, venv_dir, python_exe=python_bin)
write_features(features, out)
+
+ # The payload venv was built from this exact lock and feature set. Publish
+ # that state so the first runtime sync can reuse the shipped environment
+ # instead of rebuilding it before any plugin dependencies are requested.
+ from pm.packages import Venv
+
+ facts.record_state("venv", Venv(repo_dir).expected_stamp(features, plugin_dirs=[]), features)
print(f"✓ enabled-features.json ({len(features)} extras recorded)")
# Ship the full uv cache (build-only sdist sources and wheel ZIPs are
diff --git a/tests/scripts/test_bundle_native.py b/tests/scripts/test_bundle_native.py
index 457152efe13..2245c3fd103 100644
--- a/tests/scripts/test_bundle_native.py
+++ b/tests/scripts/test_bundle_native.py
@@ -250,6 +250,10 @@ def test_bundle_stages_git_tree_and_runs_native_children_before_manifest(tmp_pat
assert not (output / "hermes-agent/untracked").exists()
assert not (output / "hermes-agent/.git").exists()
facts = Facts(output / "tools/facts.json")
+ venv_fact = facts.get("venv")
+ assert venv_fact is not None
+ assert venv_fact["extras"] == json.loads((output / "enabled-features.json").read_text())
+ assert "environment" not in venv_fact
for name in stale:
assert facts.get(name) is None
assert not (output / "tools" / f"cached-{name}").exists()