Runs custom functions in your app (frontend or backend) to access user data, trigger UI updates, and perform authenticated actions.
Client-side tools follow the OpenAI Function Calling specification.For example, for the query “What’s in my cart?”,
the agent calls get_user_cart function in your app, retrieves the user’s shopping cart data, and responds with personalized information about items, quantities, and total price.
user context access: retrieve shopping cart contents, preferences, order history, and authentication tokens
Action execution: add items to cart, apply a , update profiles, submit forms
UI interaction: trigger UI updates, show or hide elements, refine search results dynamically
Security: run in user’s security context with proper authentication
Flexibility: use existing frontend or backend APIs without additional infrastructure
Client-side context: access local storage, session data, and other browser-specific states
Security: Runs in your app’s security context. Agent Studio never stores credentials. Always validate authentication, sanitise inputs, and enforce access control. For more information, see Client-side security patterns.
You must configure client-side tools in two places:
{ "type": "function", "function": { "name": "add_to_cart", "description": "Adds a product to the user's shopping cart. Use this when the user wants to purchase an item.", "strict": true, "parameters": { "type": "object", "properties": { "productId": { "type": "string", "description": "The Algolia objectID of the product to add" }, "quantity": { "type": ["integer", "null"], "description": "Number of items to add (defaults to 1 if not specified)", "minimum": 1, "maximum": 99 } }, "required": ["productId", "quantity"], "additionalProperties": false } }}
function validateAndSanitize(args) { const parsed = JSON.parse(args); // Validate productId format if (!/^[a-zA-Z0-9_-]+$/.test(parsed.productId)) { throw new Error("Invalid productId format"); } // Sanitise quantity if (parsed.quantity < 1 || parsed.quantity > 99) { throw new Error("Quantity must be between 1 and 99"); } return parsed;}
// Bad: returns full user object with sensitive fieldsreturn JSON.stringify(user);// Good: return only necessary fieldsreturn JSON.stringify({ name: user.name, email: user.email, // Password, tokens, and so on are excluded});