HKUDS/nanobot · error · RuntimeError

maximum exec sessions reached

Error message

maximum exec sessions reached ({self.max_sessions})

What it means

Raised by ExecSessionManager.start after cleanup of dead sessions when the number of live sessions is already at max_sessions. Each shell session holds process and buffer resources, so the cap bounds concurrent exec sessions per manager.

Solutions

  1. Poll and finish existing sessions (poll with timeout until exit) before starting new ones
  2. Raise the max_sessions limit in configuration if more concurrent shells are genuinely needed
  3. Reuse an existing session for the command instead of opening another
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nanobot/agent/tools/exec_session.py:296 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26). Data as JSON: /api/errors/71d310a576a2dc16. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/agent/tools/exec_session.py:296

    async def start(
        self,
        *,
        command: str,
        cwd: str,
        env: dict[str, str],
        timeout: int | None,
        shell_program: str | None,
        login: bool,
        yield_time_ms: int,
        max_output_chars: int,
        owner_session_key: str | None = None,
    ) -> tuple[str, _SessionPoll]:
        async with self._lock:
            if self._closed:
                raise RuntimeError("exec session manager is closed")
            await self._cleanup_locked()
            if len(self._sessions) >= self.max_sessions:
                raise RuntimeError(f"maximum exec sessions reached ({self.max_sessions})")
            process = await self._spawn(command, cwd, env, shell_program, login)
            session_id = uuid.uuid4().hex[:12]
            session = _ExecSession(
                session_id=session_id,
                process=process,
                command=command,
                cwd=cwd,
                timeout=timeout,
                owner_session_key=owner_session_key,
                process_tree=True,
            )
            self._sessions[session_id] = session

        poll = await session.poll(yield_time_ms, max_output_chars)
        if poll.done:
            async with self._lock:
                self._sessions.pop(session_id, None)
        return session_id, poll

View on GitHub (pinned to 42f37dc4c0)