Skip to content

bug(ansible): autobot-ai-stack crash-loops — systemd PYTHONPATH omits /opt/autobot, so 'No module named autobot_shared' #10121

Description

@mrveiss

Summary

autobot-ai-stack.service (the AI Processing Stack / agent router on :8080) crash-loops indefinitely — on the live install NRestarts=2968, status=1/FAILURE every ~5–10s since the 06-11 install. This is the real cause of the Code Sync / dashboard panel showing "AI Stack (ChromaDB): Connection refused" and "chromadb: Connection refused" (the panel probes the down :8080 server). ChromaDB itself (:8100) is healthy.

Root cause

The unit imports autobot_shared:

ai_api_server.py → agents.base_agent → src/agents/__init__ → kb_librarian_agent →
from autobot_shared.logging_manager import get_logger
→ ModuleNotFoundError: No module named 'autobot_shared'
  • The ai-stack unit sets Environment="PYTHONPATH=/opt/autobot/autobot-ai-stack:/opt/autobot/autobot-ai-stack/src:/opt/autobot/autobot-backend" — it omits /opt/autobot, where the standalone autobot_shared package lives.
  • autobot_shared is not installed into the backend venv's site-packages either: env -i .../venv/bin/python -c "import autobot_shared" → ModuleNotFoundError (it only resolves when /opt/autobot happens to be on PYTHONPATH).
  • The autobot-backend.service unit works only because its PYTHONPATH explicitly includes an autobot_shared path; the ai-stack unit template was never given the same.

Impact

AI Stack server permanently down → agent-router / AI-stack-backed features unavailable; dashboard shows ChromaDB-related services as "Connection refused" even though ChromaDB is fine; ~3000 restarts burning CPU.

Fix direction (repo)

In the ai-stack role's systemd unit template, add the standalone shared path to PYTHONPATH (…:/opt/autobot or the explicit /opt/autobot/autobot_shared parent) — mirroring the backend unit — OR install autobot_shared into the shared venv's site-packages so PYTHONPATH isn't load-bearing. Reconcile with #10020 (single authoritative autobot_shared).

Repro

Co-located install → systemctl status autobot-ai-stack shows auto-restart loop; sudo -u autobot env -i PYTHONPATH=<unit value> .../venv/bin/python -c "import autobot_shared" → ModuleNotFoundError.

Part of #9919 (deployment-install); related to #10020.

Activity

  1. mrveiss commented on Jun 14, 2026

    @mrveiss
    OwnerAuthor

    Verified the fix is sufficient (live install)

    Simulated the fix by adding /opt/autobot to the ai-stack PYTHONPATH and importing the actual uvicorn entrypoint as the autobot user against the deployed code:

    ```
    PYTHONPATH=/opt/autobot:/opt/autobot/autobot-ai-stack:/opt/autobot/autobot-ai-stack/src:/opt/autobot/autobot-backend
    .../autobot-backend/venv/bin/python -c "import ai_api_server"
    → IMPORT OK — app = FastAPI (LocalLLM/Ollama + agent router initialize cleanly)
    ```

    So the missing /opt/autobot on PYTHONPATH is the only blocker — there is no second-order import/init failure behind it. Adding the standalone shared path to the unit template (or installing autobot_shared into the venv) clears the crash loop and the AI Stack starts. Note: takes effect on a node only after redeploy/reinstall (the co-located self-node redeploy path is itself blocked by #10095/#10109).

  2. mrveiss commented on Jun 14, 2026

    @mrveiss
    OwnerAuthor

    Fix implemented + verified — PR held on queue limit

    Committed on branch `issue-10121` (`a4861a82c`): in `roles/ai-stack/templates/autobot-ai-stack.service.j2`, appended the standalone shared path to PYTHONPATH, mirroring the backend unit (#10020):

    ```
    PYTHONPATH={{ ai_install_dir }}:{{ ai_install_dir }}/src:{{ backend_install_dir }}:{{ ai_install_dir | dirname }}/autobot_shared:{{ ai_install_dir | dirname }}
    ```
    renders to …:/opt/autobot/autobot_shared:/opt/autobot. Verified: template renders cleanly, and a clean-env import with that exact PYTHONPATH loads ai_api_server (FastAPI app + LLM/agent init) with no error.

    PR not yet opened — the Dev_new_gui PR queue is at the project limit (5 open). Will push + open the PR as soon as a slot frees (or on request). Branch is committed so the work is safe.

  3. mrveiss commented on Jun 14, 2026

    @mrveiss
    OwnerAuthor

    Closed — merged to Dev_new_gui via PR #10130. Commit: 99c06f884. ai-stack unit PYTHONPATH now includes /opt/autobot/autobot_shared:/opt/autobot (mirrors the backend unit, #10020), resolving the ModuleNotFoundError: autobot_shared crash loop (NRestarts 2968). Verified the entrypoint imports cleanly with this path; smoke-test green. Takes effect on redeploy/reinstall (self-node redeploy path tracked separately in #10095/#10109). Part of #9919.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions