Repository navigation
modly-cli: start the API with the same setup as the desktop app - #391
Merged
lightningpixel merged 2 commits intoOct 31, 2026
Merged
Conversation
`dev serve-api` / `dev ensure-server --start` ignored dependenciesDir from settings.json. If the dependencies live on another drive (mine are on F:), the venv isn't found and it falls back to whatever Python runs the CLI, which doesn't have the backend deps. It now checks dependenciesDir first, and passes the env vars the Electron bridge sets: PYTHONIOENCODING=utf-8, MODLY_LLM_DIR (agentDir) and MODLY_NODE_EXECUTABLE (Modly.exe) for the installed app. Added two tests; the existing ones still pass.
… the desktop bridge The started API inherited PYTHONHOME, PYTHONPATH, VIRTUAL_ENV, CONDA_PREFIX and the PIP_* variables of whatever shell ran the CLI. From a conda env or an activated venv, these point Modly's venv interpreter at foreign site-packages, or keep it from starting at all. They are now removed, the same list Electron's cleanPythonEnv() strips. _default_python also tried the api's dev .venv before the app's venv, the reverse of the PythonBridge. The app's venv (dependenciesDir, then the default dependencies folder) now comes first, the dev .venv second.
lightningpixel
approved these changes
Oct 31, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I wanted to run the backend without the desktop app and used
agent.py dev ensure-server --start. It started the wrong Python.My Modly dependencies live on another drive (
dependenciesDirin settings.json points toF:\Modly\dependencies)._default_pythonnever looked there, so it fell back tosys.executable, which is my system Python without any of the backend packages:Changes:
_default_pythonchecksdependenciesDir/venvfrom settings.json before the old fallbacks (settings are now loaded before the Python is resolved).PYTHONIOENCODING=utf-8,MODLY_LLM_DIRfromagentDir, andMODLY_NODE_EXECUTABLEpointing atModly.exewhen the CLI runs against an installed app. Values already in the environment are left alone.Added two tests for this. The whole
test_agent.pypasses (34 tests), and I checked it for real:ensure-server --start --detach --api-dir <installed app>/resources/apibrings the API up and/model/allanswers.