Skills & Code Execution
Create skill scripts with 7-layer sandbox security
Skills & Code Execution
Skills are reusable code scripts that agents can execute in a secure sandbox. They extend agent capabilities beyond what LLM inference alone can provide — data analysis, file processing, API calls, calculations, and more.
Overview
The platform provides a 7-layer security pipeline for code execution:
- Cedar Policy Check — is this agent allowed to execute code?
- Code Pre-Scan — static analysis for dangerous patterns (eval, exec, network calls)
- Container Isolation — execution runs in an ephemeral Kubernetes pod
- Seccomp Profile — syscall filtering blocks dangerous operations
- Network Policy — outbound network access is blocked by default
- Output Secret Scan — scan stdout/stderr for leaked credentials
- Behavioral Monitoring — detect anomalous execution patterns
Creating a Skill
In Agent Studio
- Navigate to Studio > Skills
- Click Create Skill
- Fill in the skill metadata:
| Field | Description |
|---|---|
| Name | Descriptive name (e.g., "CSV Analyzer") |
| Description | What the skill does — shown to the LLM for tool selection |
| Language | python, javascript, typescript, or bash |
| Timeout | Max execution time (default: 30s, max: 120s) |
| Input Schema | JSON Schema defining expected inputs |
| Output Schema | JSON Schema defining expected outputs |
- Write the skill script in the Monaco editor
- Test with sample inputs
- Assign to agents
Skill Script Structure
Skills receive input as a JSON object and must produce output on stdout:
Python Example:
import json
import sys
# Input is passed as JSON on stdin
input_data = json.loads(sys.stdin.read())
# Your logic here
query = input_data.get("query", "")
data = input_data.get("data", [])
# Process...
result = {"answer": f"Processed {len(data)} rows for: {query}"}
# Output must be JSON on stdout
print(json.dumps(result))
JavaScript Example:
const input = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf8'));
const result = {
answer: `Processed ${input.data?.length || 0} items`,
timestamp: new Date().toISOString()
};
console.log(JSON.stringify(result));
Input Schema
Define what your skill expects using JSON Schema:
{
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The analysis question to answer"
},
"data": {
"type": "array",
"description": "Array of data rows to analyze",
"items": { "type": "object" }
},
"format": {
"type": "string",
"enum": ["summary", "detailed", "chart"],
"description": "Output format preference"
}
},
"required": ["query"]
}
The LLM uses this schema to understand how to call your skill and what parameters to provide.
Safe Libraries
The Python sandbox includes a curated set of pre-installed libraries:
Data Analysis
pandas— DataFrames and data manipulationnumpy— Numerical computingscipy— Scientific computing and statistics
Visualization
matplotlib— Charts and plots (saves to file, returned as base64)
Text Processing
re(built-in) — Regular expressionsjson(built-in) — JSON parsingcsv(built-in) — CSV reading/writingtextwrap(built-in) — Text formatting
Date/Time
datetime(built-in) — Date and time manipulationcalendar(built-in) — Calendar operations
Math
math(built-in) — Mathematical functionsstatistics(built-in) — Statistical functionsdecimal(built-in) — Precise decimal arithmetic
Utilities
collections(built-in) — Specialized container typesitertools(built-in) — Iterator building blocksfunctools(built-in) — Higher-order functionshashlib(built-in) — Secure hashingbase64(built-in) — Base64 encoding/decodingurllib.parse(built-in) — URL parsing (no network access)
Not Available (Blocked by Security)
requests,urllib3,httpx— No outbound HTTPsubprocess,os.system— No shell executionsocket— No raw network accessctypes,cffi— No native code executionpickle— Blocked due to deserialization risks
Assigning Skills to Agents
Skills are linked to agents through the agent designer:
- Open your agent in Studio > Agents > [Agent]
- Go to the Skills tab
- Click Assign Skill and select from available skills
- The skill appears as an MCP tool that the LLM can invoke
Note: The agent must be saved before skills can be assigned (skills are linked records in the database).
Skill Visibility
Skills have visibility settings similar to agents:
- Public — available to all agents in the tenant
- Restricted — only available to specific agents
- Private — only available to the creating builder's agents
Error Handling
In Your Script
Always handle errors gracefully and return structured error information:
import json, sys
try:
input_data = json.loads(sys.stdin.read())
# ... your logic ...
result = {"status": "success", "data": processed_data}
except json.JSONDecodeError:
result = {"status": "error", "message": "Invalid input JSON"}
except Exception as e:
result = {"status": "error", "message": str(e)}
print(json.dumps(result))
sys.exit(0) # Always exit cleanly — non-zero triggers sandbox alert
Platform Error Handling
The platform handles these failure modes:
- Timeout — script killed after timeout seconds, returns timeout error
- Memory limit — container OOM-killed, returns resource error
- Security violation — blocked by pre-scan or seccomp, returns security error
- Output too large — stdout truncated at 1MB
Testing Skills
In the Skill Editor
Use the Test panel in the skill editor:
- Enter sample input JSON
- Click Run
- View stdout, stderr, exit code, and execution time
- Iterate on the script
In the Playground
Test skills through an agent in the Playground:
- Select an agent with the skill assigned
- Ask the agent to perform a task that requires the skill
- Observe the tool call in the trace view
- Verify the skill output is correctly interpreted by the LLM
Best Practices
- Keep skills focused — one skill per task, not mega-scripts
- Validate inputs early — check for required fields before processing
- Return structured data — JSON output that the LLM can parse
- Handle edge cases — empty data, missing fields, invalid formats
- Log to stderr — use
print(..., file=sys.stderr)for debugging (visible in traces) - Respect timeouts — process data in chunks for large datasets
- Use type hints — helps both you and the LLM understand the contract
Next Steps
- Knowledge Bases Guide — feed data to your skills via knowledge bases
- Tool Integration Guide — register skills as MCP tools
- Agent Design Patterns — combine skills with other capabilities