Skill System
The Skill System allows the host application to expose business capabilities to the AI. You simply register functions, and the AI can call them via scripts — no extra adaptation needed, and documentation is auto-generated.
Two Registration Approaches
Section titled “Two Registration Approaches”| Declarative (Recommended) | Imperative (Advanced) | |
|---|---|---|
| Registration Method | Set agentConfig property | Call defineRegistry |
| Ease of Use | Zero config, works out of the box | Requires manual management |
| Use Case | Most scenarios | Dynamic or conditional registration needed |
Declarative registration example:
agent.agentConfig = { name: 'MyApp', persona: 'You are a ... assistant', groups: [{ name: 'editor', description: 'Editor operations', functions: [ { name: 'getCode', description: 'Get the current code in the editor', handler: () => editor.getCode() } ] }]};💡 After setting
agentConfig, the system automatically creates the Registry and completes function registration — the entire process requires no manual intervention.
Function Definition
Section titled “Function Definition”Each function consists of the following fields:
| Field | Type | Description |
|---|---|---|
name | string | Function name |
description | string | Function description, included in auto-generated documentation |
parameters | ParameterDef[] | Parameter definition array (ParameterDef[] format) |
returns | object | Return value definition |
handler | function | Execution function (supports async) |
hooks | object | UI hooks (see Hook System) |
parameters uses ParameterDef[] array format to describe parameters, enabling the AI to generate correct call code:
{ name: 'createOrder', description: 'Create a new order', parameters: [ { name: 'productId', schema: { type: 'string', description: 'Product ID' }, required: true }, { name: 'quantity', schema: { type: 'number', description: 'Quantity' }, required: false } ], handler: async ({ productId, quantity }) => { return await api.createOrder(productId, quantity ?? 1); }}💡 Each parameter consists of
name(parameter name),schema(parameter definition in OpenAPI Schema format), andrequired(whether it is required).
Function Groups
Section titled “Function Groups”Functions are organized through groups; group name + function name = full invocation path:
Groups keep function namespaces clear and organized, avoiding naming conflicts.
AI Invocation Method
Section titled “AI Invocation Method”The AI executes code in a sandbox via the script tool, using Proxy chain syntax to call functions:
// Proxy chain invocation — natural API styleawait rtcAgent.order.create({ productId: '123', quantity: 2 });
// Equivalent direct callawait rtcAgent.execute('order.create', { productId: '123', quantity: 2 });💡 After reading the auto-generated function documentation, the AI knows how to call these functions — no extra configuration needed.
Hook System
Section titled “Hook System”Hooks allow the host to inject custom logic at various stages of function execution:
| Hook | Trigger | Description |
|---|---|---|
onStart | Before execution | Can throw CancelledError to cancel execution |
onSuccess | After success | Runs asynchronously, does not block return |
onError | After failure | Runs asynchronously, does not block return |
onProgress | Progress update | Triggered when handler calls onProgress(n) |
onStart is the only hook that can intercept execution — ideal for confirmation dialogs, permission checks, etc.
Auto-generated Documentation
Section titled “Auto-generated Documentation”Each time a function is registered, the system generates comprehensive documentation:
| Generated Content | Description |
|---|---|
| Function Docs | Includes description, parameter table, return values, and call examples |
| INDEX.md | Function index; the AI uses this to discover available functions |
| AGENT.md | Updates the Agent capability description |
📌 The AI learns how to use functions by reading this documentation — documentation quality directly affects the AI’s calling accuracy.
Scenarios
Section titled “Scenarios”Scenarios load business workflow documentation, telling the AI how to handle specific business processes:
| Feature | Description |
|---|---|
| Scenario Docs | Business workflow descriptions in Markdown format |
| Loading Method | Specified via the <rtc-agent scenarios-url="..."> attribute |
| Storage Location | /scenarios/{slug}.md |
| AI Usage | AI reads scenario docs to understand business processes and operational guidelines |
For example, you can write scenario docs like “How to handle refunds” or “How to create an order”, and the AI will execute operations according to your business specifications.
Next Steps
Section titled “Next Steps”- RTC Protocol — Learn about the core mechanism for AI calling frontend tools
- Virtual File System — Learn where function docs and scenario docs are stored
- Command System — Learn about user-facing command interaction capabilities