agent_functions_create_code
Create a sandboxed Code function with saved tests, for logic the receptionist runs on live calls (calculations, lookups in fixed data). Read agent_functions_get_guide first for the main(input, context) contract. Required: name, description, instruction, codeLanguage, codeSource, inputSchema (root object field whose children are the arguments) and 1-25 codeTestCases. Checks plan capacity and returns upgrade_required when the plan has no room. Pass agentId to attach it once its tests pass. To call an outside URL use agent_functions_create_http instead; to change an existing function use agent_functions_update_code. Show the exact function name, receptionist, behaviour, active state, language and a summary of the code and tests, then get explicit confirmation before calling.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Function name the receptionist sees as a tool, e.g. "check_order_status". | |
| agentId | Yes | Optional receptionist ID from listAgents to attach the function to right away. | |
| isActive | Yes | Whether receptionists may call it. Default true. | |
| codeSource | Yes | Complete source defining main(input, context) that returns the result; see agent_functions_get_guide for the contract and sandbox limits. | |
| description | Yes | What the function does, in one or two plain sentences. | |
| inputSchema | Yes | Root input definition: a field of type "object" whose children are the arguments the receptionist passes (name, type, description, validations), e.g. {"name":"input","type":"object","children":[{"name":"orderNumber","type":"string","description":"Order number the caller gives"}]}. | |
| instruction | Yes | When and how the receptionist should call it on a live call, e.g. "Call when a caller asks where their order is; ask for the order number first." | |
| codeLanguage | Yes | Language of codeSource: PYTHON, JAVASCRIPT or TYPESCRIPT. | |
| codeTestCases | Yes | 1-25 tests run in the sandbox and saved with the function; it is attached to a receptionist only when all pass. |