-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Problem
package_agent() in src/nightshift/protocol/packaging.py only copies the single agent source file into the VM overlay at /opt/nightshift/agent_pkg/. If an agent imports sibling modules from the same project (e.g. from lib.helpers import foo), those imports fail inside the VM because the rest of the project tree was never injected.
This affects both code paths that provision VMs:
- One-shot (
run_taskintask.py:64) - Pool cold-start (
_cold_startinpool.py:210)
Why it's not caught today
All existing examples are single-file agents with no local imports — they only depend on PyPI packages (installed via uv pip install from pyproject.toml).
Root cause
The deploy CLI (deploy.py) correctly archives the entire project directory and the server stores it at storage_path. But when a run is triggered, _build_registered_agent() constructs a RegisteredAgent pointing into that tree, and then package_agent() throws away the context:
# packaging.py:42-43 — only copies the one file
source_filename = os.path.basename(module_path)
shutil.copy2(module_path, os.path.join(pkg_dir, source_filename))The manifest module is set to just the basename (e.g. "main"), not a dotted path like "agents.main".
For deployed agents, skip package_agent() entirely. The full project tree already exists on disk at storage_path:
- Write
manifest.jsonintostorage_pathat deploy time (inserver.py, after extracting the archive) - Pass
storage_pathdirectly asagent_pkg_pathto the VM overlay instead of going throughpackage_agent()
This avoids redundant copies and correctly makes all project modules available inside the VM. The one-shot run_task() path can be fixed separately if needed (by enhancing package_agent() to copy the full project tree).