Skip to content

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.

Declarative (Recommended)Imperative (Advanced)
Registration MethodSet agentConfig propertyCall defineRegistry
Ease of UseZero config, works out of the boxRequires manual management
Use CaseMost scenariosDynamic 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.

Each function consists of the following fields:

FieldTypeDescription
namestringFunction name
descriptionstringFunction description, included in auto-generated documentation
parametersParameterDef[]Parameter definition array (ParameterDef[] format)
returnsobjectReturn value definition
handlerfunctionExecution function (supports async)
hooksobjectUI 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), and required (whether it is required).

Functions are organized through groups; group name + function name = full invocation path:

Groups keep function namespaces clear and organized, avoiding naming conflicts.

The AI executes code in a sandbox via the script tool, using Proxy chain syntax to call functions:

// Proxy chain invocation — natural API style
await rtcAgent.order.create({ productId: '123', quantity: 2 });
// Equivalent direct call
await 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.

Hooks allow the host to inject custom logic at various stages of function execution:

HookTriggerDescription
onStartBefore executionCan throw CancelledError to cancel execution
onSuccessAfter successRuns asynchronously, does not block return
onErrorAfter failureRuns asynchronously, does not block return
onProgressProgress updateTriggered when handler calls onProgress(n)

onStart is the only hook that can intercept execution — ideal for confirmation dialogs, permission checks, etc.

Each time a function is registered, the system generates comprehensive documentation:

Generated ContentDescription
Function DocsIncludes description, parameter table, return values, and call examples
INDEX.mdFunction index; the AI uses this to discover available functions
AGENT.mdUpdates 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 load business workflow documentation, telling the AI how to handle specific business processes:

FeatureDescription
Scenario DocsBusiness workflow descriptions in Markdown format
Loading MethodSpecified via the <rtc-agent scenarios-url="..."> attribute
Storage Location/scenarios/{slug}.md
AI UsageAI 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.

  • 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