Skip to main content
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. Screenshot of a 'Configure client-side tool' dialog with fields for 'Tool name', 'Description', and JSON 'Input schema', plus 'Cancel' and 'Update tool' buttons.

How client-side tools work

  • 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:
  • Agent Studio: to define the tool schema.
  • Your frontend or backend code to run the tool.

Agent Studio configuration

Define your tools in your agent using JSON schema format. For example:
JSON

Required fields

  • type: must be "function"
  • function.name: function name (3-64 characters, alphanumeric and underscores only)
  • function.description: clear explanation of what the tool does and when to use it
  • function.parameters: JSON schema object
    • type: must be "object"
    • properties: object defining each parameter with type and description
    • required: array of required parameter names (can be empty)
    • additionalProperties: set to false for strict mode. If you’re using strict mode:
      • All fields in properties must be in required
      • Use ["type", "null"] for optional fields (for example, "type": ["string", "null"])
      • Always set additionalProperties: false for objects
      • Use enum for restricted values
      • Set minimum and maximum constraints for numbers
  • function.strict: set to true to ensure reliable schema adherence (recommended for production)

JSON schema

JSON
Implementation steps:
  1. Define your tool using JSON schema (follows OpenAI Function Calling format)
  2. Add the tool to your agent with an API or using Other tools in the dashboard

Frontend or backend code configuration

Run tools from your frontend or backend code. For example:
JavaScript
For more information about how to implement client-side tools with the InstantSearch Chat UI component, see Client-side tools integration.

Advanced usage

Strict mode

Strict mode ensures the LLM reliably adheres to your JSON Schema instead of using “best-effort” matching.
JSON
Potential issues:
  • LLM might omit optional fields unpredictably
  • Field types may not match exactly
  • Additional unexpected fields might be included

Strict mode requirements

  • All fields in properties must be in required
  • Use ["type", "null"] for optional fields (for example, "type": ["string", "null"])
  • Set additionalProperties: false for all objects
  • The LLM strictly follows the schema (no best-effort guessing)

Benefits of strict mode

  • Predictable function calls every time
  • Prevents schema drift
  • Easier debugging (failures are schema violations, not interpretation issues)
  • Recommended for production use

Render dynamic UI from agent context

Instead of returning data for the agent to describe in text, a client-side tool can return structured data that your frontend renders as UI. The agent decides what to show, and your app decides how to render it. Define a render_component tool whose parameters describe the component to render and the items it needs:
JSON
The round trip works like this:
  1. The user asks to compare or browse products.
  2. The agent searches with the Algolia Search tool, then calls render_component with a component and the matching items.
  3. Your frontend receives the tool call, renders the named component, and returns a confirmation as the tool result.
  4. The agent continues the conversation, referring to what the user now sees.
Render the payload in your frontend, then send the result back to the agent:
JavaScript

Error handling patterns

Return structured errors that the agent can interpret and explain to users:
JSON

Common error codes

  • NOT_FOUND: Resource doesn’t exist
  • UNAUTHORIZED: User lacks permissions
  • OUT_OF_STOCK: Product unavailable
  • INVALID_QUANTITY: Quantity exceeds limits
  • VALIDATION_ERROR: Input validation failed

Security

You must run client-side tools securely within your app. Use the following patterns to validate users, sanitise inputs, and enforce access control.

Always validate authentication

JavaScript

Sanitise all inputs

JavaScript

Rate limiting

JavaScript

Don’t expose sensitive data

JavaScript

See also

Last modified on July 9, 2026