The Variable System
How Variables Work
1. Define Variables in Messages
In the web app, insert variables using the/variable command:
{{variable_name}} links to a Property that defines its type.
2. Variables Sync to Schema
When you add variables, the prompt’s input schema updates automatically:3. Provide Data at Runtime
At runtime, provide values that match the schema:4. Variables Get Substituted
When converting to provider format, variables are replaced:Properties
A Property defines the type and metadata for a variable.Property Types
| Type | JSON Schema | Python | Use Case |
|---|---|---|---|
| String | {"type": "string"} | str | Text, IDs |
| Number | {"type": "number"} | float | Scores, prices |
| Integer | {"type": "integer"} | int | Counts |
| Boolean | {"type": "boolean"} | bool | Flags |
| Object | {"type": "object", ...} | Nested model | Structured data |
| Array | {"type": "array", ...} | list[T] | Collections |
Special Formats
String properties can have formats:Complex Properties
Properties can define nested structures:The render() Transformation
Why render()?
Variables must be strings for prompt injection, but your code uses typed data. Therender() method bridges this gap:
render() Input vs Output
Customizing Format
Overriderender() to control formatting:
Schemas
Input Schemas
Every prompt has an input schema that defines required variables:Tool Schemas
Tool schemas define function calling or structured output:Variable Substitution
How It Works
Variable Formats
Variables can be inline or block:| Format | Example | Description |
|---|---|---|
| Inline | The customer {{customer_name}} said... | Variable embedded in text |
| Block | {{search_results}} | Variable is entire block |
Schema Metadata
Schemas include Moxn metadata:Best Practices
Use descriptive variable names
Use descriptive variable names
customer_query is better than q. Variable names appear in code and logs.Define types precisely
Define types precisely
Use specific types (date, integer) rather than just string when possible.
Customize render() for LLM readability
Customize render() for LLM readability
Format complex data (markdown, XML) for better LLM comprehension.
Keep schemas focused
Keep schemas focused
Each prompt should have just the variables it needs.
Use arrays for variable-length data
Use arrays for variable-length data
When the number of items varies, use array types.