Description
In Backend/app/routes/fix.py, the prompt session cache (_prompt_sessions) is stored in a plain Python dictionary:
_prompt_sessions: dict[str, dict] = {}
This is used by the browser-local LLM flow:
POST /generate-prompt → stores context in _prompt_sessions and returns a session_id
POST /build-patches → retrieves context using the session_id
Impact
In a production deployment with multiple workers (gunicorn, uvicorn with --workers > 1), step 1 might hit Worker A and step 2 might hit Worker B. Since the dict is per-process, Worker B won't find the session and returns a 404 error: "Prompt session expired or not found."
This also means sessions are lost entirely on server restart (e.g., during Railway deployments).
Steps to Reproduce
- Deploy with
uvicorn main:app --workers 4
- Call
POST /api/generate-prompt → receive session_id
- Call
POST /api/build-patches with that session_id
- Observe intermittent 404 errors (~75% of the time with 4 workers)
Expected Behavior
Use a shared session store (Redis, database, or a shared-memory approach) that persists across workers. Alternatively, return all necessary context in the /generate-prompt response and pass it back in /build-patches (stateless design).
Description
In
Backend/app/routes/fix.py, the prompt session cache (_prompt_sessions) is stored in a plain Python dictionary:This is used by the browser-local LLM flow:
POST /generate-prompt→ stores context in_prompt_sessionsand returns asession_idPOST /build-patches→ retrieves context using thesession_idImpact
In a production deployment with multiple workers (gunicorn, uvicorn with
--workers > 1), step 1 might hit Worker A and step 2 might hit Worker B. Since the dict is per-process, Worker B won't find the session and returns a 404 error: "Prompt session expired or not found."This also means sessions are lost entirely on server restart (e.g., during Railway deployments).
Steps to Reproduce
uvicorn main:app --workers 4POST /api/generate-prompt→ receivesession_idPOST /api/build-patcheswith thatsession_idExpected Behavior
Use a shared session store (Redis, database, or a shared-memory approach) that persists across workers. Alternatively, return all necessary context in the
/generate-promptresponse and pass it back in/build-patches(stateless design).