HKUDS/nanobot · error · SessionMessageError

source session was not found

Error message

source session was not found

What it means

Raised by SessionMessageManager.enqueue when the resolver cannot find the source session that is sending the message. The sending agent's session has ended (or its key is unregistered), so no reply routing or rate-limit bucket can be attached.

Solutions

  1. Keep the sending session alive until after the enqueue completes
  2. Re-register or restart the sending session and retry the send
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at nanobot/agent/tools/session_messages.py:229 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/493a4a4e4120c086. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/agent/tools/session_messages.py:229

        content: str,
        expect_reply: bool,
        reply_timeout_seconds: int | None = None,
    ) -> str:
        timeout_seconds = self._validate_reply_timeout(expect_reply, reply_timeout_seconds)
        try:
            target_name = normalize_session_handle(target_handle)
        except ValueError as exc:
            raise SessionMessageError(str(exc)) from exc
        target = await asyncio.to_thread(self._handles.resolve, target_name)
        if target is None:
            raise SessionMessageError(f"session @{target_name} was not found")

        source = await asyncio.to_thread(
            self._handles.handle_for_session,
            source_session_key,
        )
        if source is None:
            raise SessionMessageError("source session was not found")
        envelope: SessionMessageEnvelope = {
            "message_id": uuid4().hex,
            "created_at_ms": int(time.time() * 1000),
            "expect_reply": expect_reply,
            "source_handle": source.name,
            "source_session_key": source.session_key,
            "target_session_key": target.session_key,
        }
        reverse_wait_key = (target.session_key, source.session_key)
        wait_key = (source.session_key, target.session_key)

        async with self._send_lock:
            now = self._clock()
            sent_at = self._sent_at.setdefault(source.session_key, deque())
            cutoff = now - _RATE_LIMIT_WINDOW_SECONDS
            while sent_at and sent_at[0] <= cutoff:
                sent_at.popleft()
            if len(sent_at) >= self._max_messages_per_minute:

View on GitHub (pinned to 42f37dc4c0)