Overview
Code generation in Rilo:- Automatic: Code is generated automatically after block verification
- Python-based: All generated code is Python
- Library Integration: Code uses Rilo’s library tools
- Sandbox Execution: Code runs in secure E2B sandboxes
You don’t need to write code yourself. Just describe what you want in natural language, and Rilo generates the code for you.
How It Works
1. Block Creation
When you create a block, you provide:- Instructions: Natural language description
- Config Fields: Configuration values
- Required Tools: Tools the block needs
2. Verification
The VerificationAgent:- Discovers required config fields
- Asks clarifying questions if needed
- Validates tool availability
3. Code Generation
The BlockCodingAgent:- Analyzes block instructions
- Identifies required tools and libraries
- Generates Python code extending
BaseBlock - Includes error handling and logging
4. Execution
Generated code:- Runs in secure E2B sandbox
- Has access to library tools
- Processes data from previous blocks
- Returns output for next blocks
Generated Code Structure
BaseBlock Extension
All generated code extends theBaseBlock class:
Library Integration
Generated code imports and uses Rilo libraries:Data Flow
Code receives data from previous blocks viainputs:
Code Capabilities
What Generated Code Can Do
✅ Execute library tools: Call methods from Rilo libraries ✅ Basic Python operations: Regex, string manipulation, data transformation ✅ File operations: Create PDF, XLSX, CSV files ✅ JSON processing: Parse and manipulate JSON data ✅ Conditionals and loops: Standard Python control flow ✅ Batch processing: Process multiple items efficientlyWhat Generated Code Cannot Do
❌ Special languages: Cannot write JavaScript, HTML, CSS, React, FastAPI, etc. ❌ System access: Cannot access environment variables or system files ❌ Shell commands: Cannot execute shell commands or system calls ❌ Direct web scraping: Must use WebOpsLibrary for web operationsCode Generation Examples
Example 1: Simple Data Processing
Instructions:Example 2: Library Tool Usage
Instructions:Code Generation Process
Step-by-Step
- Parse Instructions: Agent analyzes natural language instructions
- Identify Tools: Determines which library tools are needed
- Generate Structure: Creates BaseBlock class structure
- Add Logic: Generates Python code for the logic
- Add Error Handling: Includes try/except blocks and logging
- Validate: Checks code syntax and structure
Error Handling
Generated code includes error handling:Best Practices
Clear Instructions
Clear Instructions
Write clear, specific instructions. Vague instructions lead to unclear code generation.
Specify Tools
Specify Tools
Mention which tools you need. The agent can infer, but being explicit helps.
Provide Examples
Provide Examples
Include examples in instructions when possible. This helps the agent understand your intent.
Review Generated Code
Review Generated Code
Review generated code before execution. You can regenerate if needed.
Regenerating Code
If generated code doesn’t meet your needs:- Update Instructions: Modify block instructions to be more specific
- Adjust Config Fields: Add or modify config fields if needed
- Regenerate: Trigger code regeneration from the block editor
- Review: Check the new code and verify it matches your requirements
Code is regenerated automatically when you change block instructions or config fields that affect code generation.
Limitations
Code Generation Constraints
- Python Only: Code is always Python, not other languages
- Library Tools Only: Can only use tools from Rilo libraries
- No System Access: Cannot access system resources or credentials
- Sandbox Execution: Runs in isolated environment
What You Can’t Do
❌ Generate code in other languages (JavaScript, Go, etc.) ❌ Access environment variables or secrets ❌ Execute shell commands ❌ Direct database access (must use integration tools) ❌ Create custom libraries on the flyTroubleshooting
Code generation fails
Code generation fails
- Check that instructions are clear and specific
- Verify required tools are available
- Ensure config fields are properly set
- Try regenerating with more detailed instructions
Generated code has errors
Generated code has errors
- Review the error message in execution logs
- Update instructions to be more specific
- Check that all required config fields are set
- Regenerate code after fixing issues
Code doesn't match intent
Code doesn't match intent
- Provide more detailed instructions
- Include examples of expected behavior
- Specify exact tool methods to use
- Review and refine instructions
Related Features
- Configs - How config fields are used in code
- AI Module - Multi-agent system that generates code
- Integrations - Extend capabilities with custom tools
Code generation is continuously improving. The AI agent learns from examples and gets better at understanding your intent over time.