Variables Management
Overview
Variables can store user characteristics such as language preferences and behavioral habits. Through variable management, AI agents can dynamically memorize user information and generate personalized responses.
- Core mechanism: Variables store data in the form ofĀ
key-value pairs. - Assignment logic: The large language model automatically analyzes the semantics of user input, matches corresponding variables, and dynamically assigns values.
- Application scenario: Declare variable usage in prompts. For example,Ā change the response languages based on the userās language preference.
Type of variables
You can leverageĀ system variablesĀ andĀ user variablesĀ to address diverse business requirements. They differ in the following aspects:
| Type | Control | Data source | Read/write |
|---|---|---|---|
| System preset variables | |||
| ⢠App user variables | Preset by the platform | User behavior/device environment | Write only by the system |
| ⢠Memory variables | Preset by the platform | Long-term user interaction data | Write only by the system |
| ⢠Role variables | Preset by the platform | Panel settings | Write only by the system |
| Custom variables | Defined by developers | Proactively provided by the user or dynamically generated in a session | Omni-channel read and write |
App user variablesā
Store app usersā static information associated with smart devices to optimize the services of agents in home scenarios.
-
Typical scenario
- Weather report: Get the local real-time weather based on theĀ home latitude and longitudeĀ variables.
- Device control: Locate devices and adjust their attributes based on variables likeĀ room information,Ā home device category, andĀ device AI command attributes. For example, adjust the brightness of lights in the bedroom.
-
Available variables
Variable name Description Default value Support channels Remarks sys.categoriesHome device category Automatically generated by the system Tuya, SmartLife, and OEM App Read only sys.homeLatitudeHome latitude coordinates Automatically generated by the system Tuya, SmartLife, and OEM App Read only sys.roomsRooms in a home Automatically generated by the system Tuya, SmartLife, and OEM App Read only sys.currentTimeCurrent time in the time zone when the specified home is located Automatically generated by the system Tuya, SmartLife, and OEM App Read only sys.homeLongitudeHome longitude coordinates Automatically generated by the system Tuya, SmartLife, and OEM App Read only sys.deviceNamesList of device names Automatically generated by the system Tuya, SmartLife, and OEM App Read only sys.attributesAI command attributes for home devices Automatically generated by the system Tuya, SmartLife, and OEM App Read only -
Rules:
- How to enable: The variables are disabled by default. You can manually enable them on the developer platform.
- Data permissions:
- The data is obtained from theĀ SmartLifeĀ app,Ā TuyaĀ app, and OEM apps only.
- The data is automatically generated by the system andĀ cannot be modified manually. For example, when the user moves to another place and updates the longitude and latitude, a positioning request needs to be retriggered.
Role variablesā
Role variables are used exclusively inĀ business panel scenariosĀ such as AI dolls and smart speakers. Users can customize role attributes to enhance the interactive fidelity.
-
Typical scenario
- Child companion robot: Users can set role names (such as āLittle Helper Leleā) via theĀ
role_nameĀ variable.
- Child companion robot: Users can set role names (such as āLittle Helper Leleā) via theĀ
-
Default variables
Variable name Description Support channels Remarks sys.roleNameRole name AI toy panel Read only sys.roleIntroduceRole description AI toy panel Read only sys.roleSupplementDescSupplemental description of the role AI toy panel Read only -
Rules:
- You need to enable variables on the developer platform before you can use them.
- End users: The end users can modify the value of a role variable. The modifications take effect immediately without redeploying the agent.
For more information, seeĀ Use variables.
Memory variablesā
Store personalized data that users need toĀ retain for a long timeĀ during their interaction with agents. Support persistent reading and writing across sessions.
-
Typical scenario
- Content matching based on interests: TheĀ
sys.memoryInterestsĀ variable records user-selected hobbies and preferences, enabling the system to recommend relevant content and tailor responses during conversations. - Understand user habits through memory integration: TheĀ
sys.memoryHistoryChatSummaryĀ variable stores summaries of past conversations, maintaining contextual continuity to deliver more relevant responses.
- Content matching based on interests: TheĀ
-
Default variables
Variable name Description Support channels Remarks sys.memoryUserFullNameName. Record and summarize the userās name to facilitate personalized communication. Omni-channel Summarize each session sys.memoryInterestsHobbies and interests. Record user hobbies and interests to enable personalized content recommendations. Omni-channel Same as above sys.memoryAgeAge. Record the userās age information to optimize the interaction experience. Omni-channel Same as above sys.memoryBirthdayBirthday. Record the userās birthday information to enable reminders or greetings. Omni-channel Same as above sys.memoryProfessionProfession. Record the userās profession information to better understand their needs. Omni-channel Same as above sys.memoryGoalsAndWishesGoals and wishes. Record the userās goals and wishes to facilitate personalized support. Omni-channel Same as above sys.memoryPetsKeptAtHomeRecord the pets in the userās home to enable personalized interactions. Omni-channel Same as above sys.memoryHistoryChatSummarySummarize the userās historical conversations to maintain contextual continuity. Omni-channel Same as above -
Typical scenario
- Content matching based on interests: TheĀ
sys.memoryInterestsĀ variable records user-selected hobbies and preferences, enabling the system to recommend relevant content and tailor responses during conversations. - Understand user habits through memory integration: TheĀ
sys.memoryHistoryChatSummaryĀ variable stores summaries of past conversations, maintaining contextual continuity to deliver more relevant responses.
- Content matching based on interests: TheĀ
-
Rules:
- How to enable: The variables are disabled by default. You can manually enable them on the developer platform.
- Data permissions:
- The data is available in all deployment channels of the agent.
- The data is automatically generated by the system andĀ cannot be modified manually. For example, when the user moves to another place and updates the longitude and latitude, a positioning request needs to be retriggered.
Custom variablesā
You canĀ fully customizeĀ variable types to capture temporary states or extend business needs during dynamic interactions between users and agents, such as user roles or real-time emotions.
- Typical scenario
- Emotional awareness: Dynamically adjust the tone of the response by using theĀ
current_moodĀ variable. Value range is 0 to 10. - Identity adaptation: Switch the agentās response strategy by using theĀ
user_roleĀ variable, such as āparentā and āguestā.
- Emotional awareness: Dynamically adjust the tone of the response by using theĀ
- Definition recommendation
Examples of custom variablesā
| Variable name | Variable description | Scenario |
|---|---|---|
custom_moodLevel | Userās real-time sentiment value (0 to 10 rating) | When the userās sentiment value is detected to be ā„ 7, use a more positive tone to respond. |
custom_interactionFrequency | Statistics of user interactions on the day | If daily interactions reach ā„ 5 times, push a care reminder:Ā āWould you like to take a break?ā |
custom_preferredTopic | The most recent hashtags that users follow | Prioritize recipe-related content based onĀ custom_preferredTopic=#cooking. |
Use variables
-
Log in to theĀ Tuya Developer Platform.
-
ChooseĀ AI AgentĀ >Ā Agent DevĀ >Ā My Agent, and clickĀ Create AgentĀ orĀ Agent Management.

Variables Management -
Scroll down to theĀ VariablesĀ section and clickĀ +Ā on the right.

Variables Management -
Manage variables. On theĀ Edit VariablesĀ page, you can create custom variables, enable system variables, or enable role variable management.
-
Create a custom variable: In the section ofĀ Custom Variables, clickĀ Add, enter the variable name, description, and default value, and then clickĀ Save. It is recommended that precise variable names and descriptions be provided to enhance the agentās accuracy in hitting user data.

Variables Management -
Enable system variables. Turn on the switch to enable app user variables and memory variables. Once enabled, the variable information will be automatically quoted by system prompts.

Variables Management If you want to add a special description, you can add the usage scenario of the variable in prompts.
-
Enable role variable management: Role variables are designed for scenarios requiring predefined roles, such as AI toys and smart speakers. Role variables must be used with the panels of the specific categories. This enables end users to customize agent roles, voice tones, personalities, and other features.
-
Turn on the switch to enable the role variables group.

Variables Management -
On the page ofĀ Preset Role Management, clickĀ Add Preset RoleĀ to add official roles or custom roles.

Variables Management -
After variables are enabled, once the agent development and device linkage are completed, the preset role information will be visible on the panel when used with the AI toy panel.
-
-