HKUDS/nanobot · error · ValueError

channel 'system' is reserved for internal messages

Error message

channel 'system' is reserved for internal messages

What it means

Raised in loop.py when persisting a subagent follow-up message whose channel is 'system'. 'system' is a reserved pseudo-channel used for internal bookkeeping, so inbound/outbound routing refuses to attach user-visible messages to it.

Solutions

  1. Use a real channel identifier (e.g. websocket, telegram) when constructing the message
  2. Route internal bookkeeping through the system channel APIs instead of the message persistence path
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nanobot/agent/loop.py:2352 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/0836fdb16640cbd6. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/agent/loop.py:2352

        chat_id: str = "direct",
        sender_id: str = "user",
        media: list[str] | None = None,
        on_progress: Callable[..., Awaitable[None]] | None = None,
        on_stream: Callable[[str], Awaitable[None]] | None = None,
        on_stream_end: Callable[..., Awaitable[None]] | None = None,
        ephemeral: bool = False,
        _run_extra_hooks_for_ephemeral: bool = False,
        hooks: list[AgentHook] | None = None,
        hook_factories: list[AgentTurnHookFactory] | None = None,
        tools: ToolRegistry | None = None,
        persist_user_message: bool = True,
        runtime: LLMRuntime | None = None,
        on_runtime_admitted: Callable[[LLMRuntime], Awaitable[None]] | None = None,
        attributes: Mapping[str, Any] | None = None,
    ) -> OutboundMessage | None:
        """Process an external message directly and return the outbound payload."""
        if channel == "system":
            raise ValueError("channel 'system' is reserved for internal messages")
        metadata: dict[str, Any] = {}
        if not persist_user_message:
            metadata[turn_continuation.SKIP_USER_PERSIST_META] = True
        msg = InboundMessage(
            channel=channel, sender_id=sender_id, chat_id=chat_id,
            content=content, media=media or [], metadata=metadata,
        )
        # Share the dispatch lock so direct calls serialize with bus turns.
        lock = self._get_session_lock(session_key)
        try:
            async with lock:
                kwargs: dict[str, Any] = {
                    "session_key": session_key,
                    "on_progress": on_progress,
                    "on_stream": on_stream,
                    "on_stream_end": on_stream_end,
                    "ephemeral": ephemeral,
                }

View on GitHub (pinned to 42f37dc4c0)