Skip to content

Command System

The Command System lets users quickly trigger specific features using /command syntax. Type text starting with /, and the frontend automatically identifies the command name and arguments, dispatching them to the corresponding handler — as efficient as a terminal command line.

Commands are dispatched through different handling modes based on their implementation:

Handling ModeDescriptionExample
Frontend Direct HandlingFrontend switch case matches the command name, executes local logic or sends RPC to the backend/compact: Frontend sends RPC to call the backend compression API
Special Prefix HandlingFrontend recognizes command prefix, generates a special message (isMeta: true) for the AI/goal: Generates a goal-setting message for AI to understand the task objective
Custom CommandsHost application registers custom commands via API; frontend matches and calls the registered handler functionAny custom command registered by the host

Parsing rules:

  • The first word after / is the command name
  • The rest is the arguments (passed as raw string)
  • Command name matching priority: exact match > alias match

Commands come from two sources: system built-in commands (/compact, /export, /goal, /persona) and custom commands registered by the host application via API.


Exposes the existing auto-compression capability, allowing users to proactively trigger context compression to free up token space.

ParameterRequiredDescription
Custom instructionNoCustom summarization instruction that overrides the default compression prompt
Key RuleDescription
Asynchronous ExecutionCompression goes through a queue, does not block the current conversation
Completion NotificationPushes a notification via the Live channel when compression completes
Duplicate PreventionRepeated triggers are blocked while compression is in progress
Result FeedbackReturns {Success: true} upon completion, with notification pushed via the Live channel

Export the current session’s conversation history as a standalone HTML file for offline reading, archiving, or sharing. Pure frontend implementation — no server involvement required.

The dialog provides the following configuration:

OptionTypeDefaultDescription
Message limitSlider200Export the most recent N messages. Step size 100, max 2000. Set above current message count to export all
Include tool callsYes / NoNoWhether to include toolcall_input and toolcall_output messages
Include thinkingYes / NoNoWhether to include thinking messages

The generated HTML file contains:

ContentDescription
Session metadataTitle, creation time, message count, token statistics (input/output/cache read/cache write/total cost)
User messagesExpanded, rendered as Markdown + syntax-highlighted code
Assistant repliesExpanded, rendered as Markdown + syntax-highlighted code
Tool callsCollapsed (optional), expandable to view parameters and results
Thinking processCollapsed (optional), expandable to view AI reasoning

Filename format: rtc-{session-title}-{YYYY-MM-DD}.html

  • Illegal filename characters are replaced with hyphens
  • Title is truncated to 50 characters
  • Spaces are replaced with hyphens
RuleDescription
Exclude streaming messagesAutomatically filters out incomplete messages with streaming: true
Empty session checkShows error when the current session has no messages
Content filteringFilters tool call and thinking messages based on user options
Count truncationKeeps the most recent N messages when exceeding the limit

💡 Design principle: Export is a fully offline, frontend-only operation — the HTML file embeds all styles and can be viewed without internet access. Markdown rendering uses marked + highlight.js + DOMPurify, consistent with the component’s internal message rendering pipeline.


Switch the AI’s role/persona for the current session. After entering a role name, the AI adopts that role’s vocabulary, priorities, and typical reasoning patterns until the session ends or the command is overridden.

/persona <role-name>
ParameterRequiredDescription
Role nameYesRole description, e.g. senior-backend-engineer, product-manager, security-expert. Enter default to revert to default behavior

/persona is a session-scoped command — it stays active for the entire session after being triggered. The backend maintains the persona through two phases:

PhaseDescription
Trigger promptOn the first invocation, a system message is injected to activate the role
Sustain promptOn subsequent turns, a reminder is injected to keep the AI in character
Key RuleDescription
Session-scopedThe persona is only valid for the current session; it expires when the session closes
OverridableEnter a new /persona command to switch roles
ReversibleUse /persona default to revert to default behavior

Users describe tasks that need to be executed in a loop using natural language. The Agent understands the intent and creates a scheduled loop task that runs automatically at fixed intervals.

/loop <task description>
ParameterRequiredDescription
Task descriptionYesNatural language description of the loop task, e.g., check deployment status every 5 minutes

/loop creates a scheduled loop task through the LLM built-in tool createLoop. Once created, the system automatically triggers new Turns at fixed intervals to perform the operations described in the task, until the user cancels.

Related ToolDescription
createLoopCreate a scheduled loop task
cancelLoopCancel a loop task
completeLoopMark a loop task as completed
listLoopsList all loop tasks in the current session
pauseLoopPause a loop task
resumeLoopResume a paused loop task

The user sets a completion condition, and the AI works continuously until the condition is met. During execution, the AI self-assesses whether the goal has been achieved, declaring completion via the completeGoal tool, or cancelling via the cancelGoal tool.

/goal uses special prefix handling: after the user types /goal <condition>, the frontend sends it as a regular message. The backend detects the prefix through the command registry (GoalWorkflow) and injects a system prompt to guide the AI into the goal-setting workflow.

Unlike commands with frontend direct handling like /compact, /goal does not execute an operation immediately — it triggers a multi-turn conversation workflow:

Comparison/compact/goal
Handling modeFrontend sends RPC directlySpecial prefix → system prompt injection
Execution timingImmediateAI interprets and guides multi-turn interaction
User confirmationNot requiredRequired to confirm the goal condition

During execution, the AI continuously evaluates the goal’s completion status. When the AI determines the goal has been achieved, it calls the completeGoal tool to declare completion; when the AI determines the goal cannot be achieved or needs to be cancelled, it calls the cancelGoal tool.

ComponentResponsibility
AIPerforms work and self-assesses whether the goal is achieved, declaring state changes via completeGoal/cancelGoal tools

A Goal is an entity independent of the Session, with its own lifecycle:

StateDescription
ActiveGoal is active, AI continues working
CompletedAI declared condition achieved via completeGoal
CancelledUser manually cancelled
ExhaustedExceeded maximum round limit (default: 50 rounds)
ElementDescription
Status BarDisplays a summary of the current goal condition
Overlay PanelShows rounds executed, cumulative tokens, and runtime
Completion NotificationPops up a notification when the goal is achieved
CommandDescription
/goalDisplay current goal
/goal <condition>Set a goal
/goal clearClear the goal
Key RuleDescription
Single GoalOnly one active goal per session
Session-scopedGoals are only valid within the current session
Safety LimitMaximum round limit (default: 50 rounds) to prevent runaway execution

After command execution, the frontend provides feedback to the user via Toast notifications.

Command Feedback:

ScenarioFeedback Method
Command executed successfullyToast notification ✅
Command execution failedToast error message ❌
  • Skill System — Learn how the host registers custom functions to extend AI capabilities
  • LLM Built-in Tools — Learn about the built-in tools available to the AI during conversation
  • RTC Protocol — Learn about the remote tool calling mechanism behind commands
  • Session Management — Learn about the session context in which commands operate