Set conversation response action in a script should work when the script is called in an automation

I have noticed that the Set conversation response action works perfectly within an automation, but does not work in a script, even when the script is triggered by an automation.

Ideally, the script knows the context parent (the automation) and the action can therefore set the conversation response for the automation.


Another, similar but not actually the same, feature request: both LLM conversation agents as well as the built-in Home Assistant conversation agent should reply to the user with the error raised by a script they invoked. That way, the Stop action in a script (when coupled with the “stop with an error option”) can inform the user (invoking the script via a conversation) of what exact error took place.

<tool_response>\n{\"success\": true, \"result\": {}}\n

OK so one good place to start would be to return "success" : false to the LLM when the script it invoked failed. Extra props for embedding the reason that the script was stopped in the result variable`.

I’ve managed to make the LLM less confused when it runs a script, with this trick:

alias: Stop if not available
if:
  - alias: No popcorn.
    condition: template
    value_template: "{{ states('binary_sensor.popcorn') == 'off' }}"
then:
  - variables:
      response:
        error: Popcorn is not available
  - stop: Popcorn is not available
    response_variable: response

With that, the LLM receives:

<tool_response>\n{\"success\": true, \"result\": {"error": "Popcorn is not available"}}}\n

and tells me something to the effect that there is no popcorn available.

Of course, I would like the success variable to be false, but the stop action does not permit the response variable to be specified when there is an error (and I think it should, so we can return structured errors to the caller).

1 Like

I agree, because this would make it easier to factor out common response logic, and I’ll add that any conversation_response set in a script should be respected when the script is called directly by its entity name.

2 Likes