„Ask AI“ scenes: add an option „Allow AI to read and control devices“ for quick, side-effect-free dynamic messages

Context

@StephaneB uses the « Ask the AI » action in a scene to generate a message that changes with each execution, for example: « Tell me that the hot water at {{temperature}} °C will be ready soon, in an original sentence ». The value is already injected by a scene variable, the AI has nothing to look up in the house. It is only used to rephrase.

Observed Problem

Each execution of this action takes 15 to 20 seconds, regardless of the hardware running Gladys.

After analyzing a user’s logs, more than 95% of the time is spent in AI model calls, and the sequence is always the same:

  1. A first AI call classifies the request. As soon as a temperature or device is mentioned, the request is classified as a question about the state of the house, even if the value is already in the text.
  2. Due to this classification, Gladys forces the AI to call at least one tool. The model will therefore read the state of random devices, unrelated to the message. This is the longest step, 8 to 10 seconds.
  3. A second AI call finally writes the message.
  4. Sometimes an additional round: in one observed case, the AI decided on its own to write the message in a virtual sensor of the installation, which no one had asked it to do.

Rephrasing the question does not change anything, as this behavior is decided by Gladys before the model even reads the user’s text.

Proposal

Add a checkbox in the « Ask the AI » action of the scene editor: « Allow the AI to read and control devices ».

Checked box (current behavior, default value):

  • The AI has access to Gladys’ tools: reading states, controlling devices, virtual sensors, weather, etc.
  • This is the mode suitable for scenes like « look at the camera and react » or « check the house and notify me ».

Unchecked box:

  • Gladys no longer performs the classification step or the tool search.
  • A single AI call is sent, with the question and the optional camera image, without any tools.
  • The AI can therefore neither read nor modify anything in the house: the scene remains predictable.
  • The response time drops to 2 to 4 seconds instead of 15 to 20.

Existing scenes are not modified: without the saved option, they behave as if the box is checked.

Benefits

  • Almost instantaneous dynamic messages for the most common use of this action, simply by unchecking the box.
  • Guarantee for the user that a simple message scene will never touch their devices.
  • Reduced cost on Gladys Plus, one call instead of three or four.

What is not covered by this ticket

The sometimes overly broad classification of requests by the router (for example, the « scenes » category retained when the user asks not to create a scene) deserves a separate improvement, as it also affects the chat.

I vote for, obviously :+1: