code_tools
Write, validate, run, and save JavaScript code tools inside an agent with declared input/output variables—no server needed—then test with sample inputs before saving.
Instructions
Write, check and run CODE tools: JavaScript that runs inside the agent (no server needed), with declared input and output variables. For tools that call an HTTP API use create_agent_tool. Flow: validate → run with sample inputVars → save. Actions: validate — check syntax and the input/output contract without running Needs: code. | run — run the code once with sample inputs and return outputs / logs / errors Needs: code. | ai_edit — have AI rewrite the code for a request (returns code; does not save) Needs: agentId, code, userRequest. | save — create or update the code tool on the agent Needs: agentId, tool.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | JavaScript source of the tool. | |
| mode | No | compact (default) = light mode: long text is cut and bulky blobs are replaced by a size marker. full = complete API response. | |
| tool | No | For save: the tool definition — name, description, variablesIds / fields, and codeExecution: { enabled: true, code }. Include id to update an existing tool. | |
| paths | No | Named exit paths, if the tool branches. | |
| action | Yes | ||
| inputs | No | Declared inputs: [{ key, type: string|number|boolean|object, required? }]. | |
| strict | No | For validate / run: default true (outputs must match the contract). | |
| agentId | No | ||
| outputs | No | Declared outputs, same shape. | |
| toolName | No | ||
| inputVars | No | For run: sample values by input key. | |
| userRequest | No | For ai_edit: what to change, in plain words. | |
| toolDescription | No |