Repository navigation
bug(web): /exit in remote CLI sessions incorrectly uses send_command instead of exit_cli #8930
Description
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
- Start Kilo CLI on a remote machine and connect it to Kilo's remote sessions service.
- Create a new CLI session using the Kilo mobile app.
- Open the same session in the web interface at
app.kilo.ai. - Verify that communication works by sending a regular prompt.
- Type
/exitand select the suggested Exit the CLI command. - 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
/exitinvokes the dedicatedexit_cliremote 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:
The CLI intentionally excludes exit from executable slash commands:
export function executable(name: string): boolean {
return name !== exit.name;
}The remote handler rejects non-executable commands with unknown slash command.
Cloud SDK implementation:
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.
/compactworks correctly in the same session via the web interface.- WebSocket connections establish successfully (
101 Switching Protocols). list_commandssucceeds and returnscanExitSession: 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