OpenBMB/ChatDev · error · HTTPException

Session not found

Error message

Session not found

What it means

A session-scoped artifact endpoint looked up session_id in the websocket manager's session store and found no such session. All artifact routes delegate to _get_session_and_queue, which 404s when get_session returns falsy.

Source

Thrown at server/routes/artifacts.py:28

router = APIRouter()

MAX_FILE_SIZE = 20 * 1024 * 1024  # 20 MB


def _split_csv(value: Optional[str]) -> Optional[List[str]]:
    if not value:
        return None
    parts = [part.strip() for part in value.split(",")]
    filtered = [part for part in parts if part]
    return filtered or None


def _get_session_and_queue(session_id: str):
    manager = get_websocket_manager()
    session = manager.session_store.get_session(session_id)
    if not session:
        raise HTTPException(status_code=404, detail="Session not found")
    queue = session.artifact_queue
    if queue is None:
        raise HTTPException(status_code=404, detail="Artifact stream not available")
    return manager, queue


@router.get("/api/sessions/{session_id}/artifact-events")
async def poll_artifact_events(
    session_id: str,
    wait_seconds: float = Query(25.0, ge=0.0, le=60.0),
    after: Optional[int] = Query(None, ge=0),
    include_mime: Optional[str] = Query(None),
    include_ext: Optional[str] = Query(None),
    max_size: Optional[int] = Query(None, gt=0),
    limit: int = Query(25, ge=1, le=100),
):
    manager, queue = _get_session_and_queue(session_id)
    include_mime_list = _split_csv(include_mime)

View on GitHub (pinned to 4fb2db0ea9)

Solutions

  1. Verify the session still exists via the session listing API before polling artifacts
  2. Re-create/reconnect the session to get a fresh session_id
  3. Check for server restarts in logs that would clear in-memory sessions
  4. URL-encode the session_id exactly as returned at creation
Defensive patterns

Strategy: try-catch

Validate before calling

# call the session listing/detail API first
assert session_id in client.list_sessions(), 'session missing'

Try / catch

try:
    client.poll_artifact_events(session_id)
except HTTPError as e:
    if e.response.status_code == 404 and e.response.json()['detail'] == 'Session not found':
        session_id = client.create_session()  # recover by recreating

Prevention

When it happens

Trigger: GET /api/sessions/{session_id}/artifact-events or GET /api/sessions/{session_id}/artifacts/{artifact_id} with a session_id that was never created, was removed, or belongs to a server that restarted and lost in-memory state.

Common situations: Server restart wiped the in-memory session store while the client kept an old session_id; typo in session_id; session already cleaned up/expired.

Related errors


AI-assisted analysis of OpenBMB/ChatDev@4fb2db0ea9 (2026-08-27). Data as JSON: /api/errors/aab88c83a1814bcc. Report an issue: GitHub.