Skip to content

bug(web): /exit in remote CLI sessions incorrectly uses send_command instead of exit_cli #8930

Open

Description

@JohanForngren

Bug description

When controlling a remote Kilo CLI session from app.kilo.ai, the /exit slash command fails with:

Connection failed. Please retry in a moment.

The web client incorrectly dispatches /exit using send_command with command: "exit", even though the CLI explicitly rejects exit as an executable slash command.

The CLI returns unknown slash command.

The dedicated exit_cli command already exists in the remote protocol and is supported by the Cloud Agent SDK.

Steps to reproduce

  1. Start Kilo CLI on a remote machine and connect it to Kilo's remote sessions service.
  2. Create a new CLI session using the Kilo mobile app.
  3. Open the same session in the web interface at app.kilo.ai.
  4. Verify that communication works by sending a regular prompt.
  5. Type /exit and select the suggested Exit the CLI command.
  6. Submit the command.

Actual behavior

  • The web UI displays Connection failed. Please retry in a moment.
  • The CLI returns unknown slash command.
  • The requested exit is not successfully executed.

Expected behavior

  • /exit invokes the dedicated exit_cli remote command.
  • The session exits/detaches successfully.
  • The web UI updates accordingly without displaying a connection error.

WebSocket evidence

Captured using Microsoft Edge DevTools, Network → Socket → web?ticket=... → Messages.

1. The CLI advertises support for exiting the session

The web client sends list_commands:

{
  "type": "command",
  "id": "<request-id>",
  "command": "list_commands",
  "connectionId": "<connection-id>",
  "sessionId": "<session-id>",
  "data": {
    "protocolVersion": 1
  }
}

The response includes (excerpt):

{
  "type": "response",
  "id": "<request-id>",
  "result": {
    "protocolVersion": 1,
    "commands": [
      {
        "name": "exit",
        "description": "Exit the CLI",
        "hints": []
      }
    ],
    "canExitSession": true
  }
}

The CLI therefore explicitly advertises that exiting the session is supported.

2. The web client sends /exit using the wrong command

Actual outgoing WebSocket message (identifiers redacted):

{
  "type": "command",
  "id": "<request-id>",
  "command": "send_command",
  "connectionId": "<connection-id>",
  "sessionId": "<session-id>",
  "data": {
    "protocolVersion": 1,
    "command": "exit",
    "arguments": "",
    "messageID": "<message-id>"
  }
}

3. The CLI rejects it

Actual incoming WebSocket response:

{
  "type": "response",
  "id": "<request-id>",
  "error": "unknown slash command"
}

The web UI subsequently displays the generic connection error rather than the actual command error.

Root cause analysis

The relevant code appears to confirm the issue.

CLI implementation:

[packages/opencode/src/kilo-sessions/remote-command.ts](https://github.com/Kilo-Org/kilocode/blob/main/packages/opencode/src/kilo-sessions/remote-command.ts)

The CLI intentionally excludes exit from executable slash commands:

export function executable(name: string): boolean {
  return name !== exit.name;
}

[packages/opencode/src/kilo-sessions/remote-sender.ts](https://github.com/Kilo-Org/kilocode/blob/main/packages/opencode/src/kilo-sessions/remote-sender.ts)

The remote handler rejects non-executable commands with unknown slash command.

Cloud SDK implementation:

[packages/cloud-agent-sdk/src/cli-live-transport.ts](https://github.com/Kilo-Org/cloud/blob/main/packages/cloud-agent-sdk/src/cli-live-transport.ts)

The SDK already exposes exitSession(), which uses the dedicated exit_cli protocol command.

The web UI appears to route /exit through the generic slash-command path instead of this dedicated method.

Additional observations

  • Regular prompts work from the web interface, including successful responses from the agent.
  • /compact works correctly in the same session via the web interface.
  • WebSocket connections establish successfully (101 Switching Protocols).
  • list_commands succeeds and returns canExitSession: true.
  • The Kilo mobile app can create, control, and exit sessions on the same remote host.
  • This is reproducible with a remote CLI session created from the mobile app and subsequently opened in the web interface.

These observations suggest that this is specifically a web-client command-routing issue, not a general connectivity or CLI capability problem.

Environment

  • Web client: https://app.kilo.ai
  • Browser: Microsoft Edge
  • Agent host: Remote Kilo CLI running on a VM
  • Session platform: CLI
  • Reported remote protocol version: 7.8.18
  • Organization: Kilo organization with remote CLI sessions enabled
  • Mobile client: Kilo mobile app (working)

Related: [Kilo-Org/kilocode#14405](Kilo-Org/kilocode#14405) – remote detach/exit verification (related area, not necessarily the same bug).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions