Skip to content

Remote Tool Calling

Remote Tool Calling (RTC) is the core protocol of RTC Agent. It reverses the traditional invocation direction: instead of the frontend calling backend APIs, AI calls frontend tools — file read/write, script execution, and business API calls all happen within the user’s browser.

TraditionalRTC
Tool ExecutionServerFrontend
Data FlowTo the cloud 🔒Stays on user’s device 🔐
PrivacyData passes through serverEnd-to-end, data never leaves the browser
ObservabilityBlack boxFully visible to the user

A single RTC call goes through the following steps:

💡 Key Design: After pushing the RTC, the server suspends the Turn and saves a Checkpoint to Redis. Even if the server restarts, it can recover from the Checkpoint — the user is completely unaware.

The RTC protocol defines 8 built-in tools covering file system operations, precise editing, and script execution:

ToolFunctionKey ParametersStatus
🔍 lsList directory contentspath (default /)Available
📖 readRead file contentspath, offset / limit (pagination)Available
✏️ writeWrite to file (full overwrite)path, contentAvailable
🔧 editPrecise text replacementpath, old_string, new_string, replace_allAvailable
🔎 grepSearch by contentpattern (regex), pathAvailable
📁 findSearch by namepattern (glob), pathAvailable
⚡ scriptExecute JavaScriptaction (save / run / eval), codeAvailable
💬 askUserAsk user questions (interrupts turn)questions (1-4 multiple choice)Available

💡 The write tool performs full-content overwrites. For partial edits, use the edit tool (precise string replacement) or the rtcAgent.fs.write() API in the script tool.

These 8 tools give the AI a complete file operation interface — operating on the frontend virtual file system just like working with a local terminal.

💡 All RTC tools follow the same lifecycle: the server creates an RTC record, saves a checkpoint, pauses the turn, pushes an event to the frontend, the frontend executes the tool, submits the result, the server restores the checkpoint, and reasoning continues.

Each RTC call has a well-defined lifecycle state:

StatePrompt Seen by AIDescription
Pending[Tool Pending]Waiting for frontend to receive
Sent[Tool Pending]Delivered to frontend
Executing[Tool Pending]Currently executing
CompletedTool outputExecution successful, result returned
Failed[Tool Error]Execution failed
Timeout[Tool Timeout]Execution timed out
Rejected[Tool Rejected]User rejected execution

Different work modes determine whether tool execution requires user confirmation. See Work Modes for the full permission matrix.

📌 Core Principle: Read-only operations are always safely allowed; write only requires confirmation in the highest-alertness mode; script can execute arbitrary code, so it requires user confirmation in all modes except bypass.

The core reliability guarantee of RTC is the Checkpoint:

FeatureDescription
Storage LocationRedis, TTL 24 hours
Crash RecoveryCan recover from Checkpoint after server restart
User ExperiencePerceived as “AI waiting for tool result before continuing”

RTC result reporting follows the 100% delivery principle:

Why must it be 100% delivered? Because the AI is waiting for the tool result to continue reasoning. If the result is lost, the AI will wait indefinitely.

MechanismDescription
Infinite RetryFailed submissions are automatically retried, with no give-up mechanism
Idempotency GuaranteeRepeated submissions with the same client_id return success
Exponential BackoffRetry intervals: 1s → 2s → 4s → … → capped at 30s

RTC calls within the same session are strictly serialized to avoid file conflicts caused by concurrency:

The next RTC is processed only after the current one completes. This is transparent to the user — the AI naturally completes each operation in sequence.

The rtc-queue uses a hold-lock mode to handle consecutive work for the same Session: after completing a work item, the Worker retains the session lock and continues claiming more work from the same Session until the queue is empty, then releases the lock. This ensures that turn-loop agents (e.g., executing multiple RTC tool calls in sequence) don’t need to re-compete for the lock between operations, improving efficiency for consecutive processing.

💡 This is an internal optimization, completely transparent to users. Users simply experience the coherence of AI operations — no unnecessary waits between multiple tool calls.