Execute Code
rlm_execute_codeExecute JavaScript code to manipulate and aggregate data, access context, retrieve metadata, manage variables, and format output.
Instructions
Execute JavaScript code in the session's REPL environment.
Available functions:
print(...args) - Output text
getContext(id) - Get context content
getContextMetadata(id) - Get context metadata
len(str), slice(str,s,e), split(str,sep), join(arr,sep)
search(pattern,text,flags), findAll(pattern,text), replace(text,pattern,repl)
range(start,end,step), map(arr,fn), filter(arr,fn), reduce(arr,fn,init)
setVar(name,value), getVar(name), listVars()
setAnswer(content,ready), getAnswer()
JSON.parse(), JSON.stringify()
Use this for custom data manipulation and aggregation.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "rlm_execute_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | JavaScript code to execute | |
| session_id | No | Session ID |