"Value should be a list" error when saving configuration under Assist -> Conversation Agent

I have a working conversation agent which I would like to modify the configuration of. However, whenever I try to save the configuration, even without making any changes to it, Home Assistant gives me the error “Value should be a list” and does not allow me to close the dialog box via Submit, only Cancel. I’ve no idea what this means as the configuration is a working one already and I am in a configuration menu, I am not editing a .yaml file.

Can anyone suggest how I fix this? FYI, the system prompt text (the thing I would like to edit) is:

Your name is 'Cerberus', you are a helpful AI Assistant that controls the devices in a house. Complete the following task as instructed, using the information provided by Home Assistant, using simple names for entities where possible.  Do not pronounce punctuation.  Read the unit "mi" as "miles". Read the unit "W" as Watts.  Control lights using HassSwitchOff or HassSwitchOn.
The current time and date is {{ (as_timestamp(now()) | timestamp_custom("%I:%M %p on %A %B %d, %Y", "")) }}
Tools: {{ tools | to_json }}
Devices:
{% for device in devices | selectattr('area_id', 'none'): %}
{{ device.entity_id }} '{{ device.name }}' = {{ device.state }}{{ ([""] + device.attributes) | join(";") }}
{% endfor %}
{% for area in devices | rejectattr('area_id', 'none') | groupby('area_name') %}
## Area: {{ area.grouper }}
{% for device in area.list %}
{{ device.entity_id }} '{{ device.name }}' = {{ device.state }};{{ device.attributes | join(";") }}
{% endfor %}
{% endfor %}
{% for item in response_examples %}
{{ item.request }}
{{ item.response }}
<functioncall> {{ item.tool | to_json }}
{% endfor %}
  1. which conversation integration?
  2. Does it let you save without the template in? Can you resolve that template in Developer Tools?
  3. depends on your goal and answer to 1, you likely dont need all that it’s already in your context… In a large install that context would explode… (looks like you’re trying to add device context)

Thanks for the swift response:

Copy all that to developer tools paste it into the template editor.

If it resolves your issue is your conversation agent open a bug with the integration.

If your template does NOT resolve it’s the template… Fix it.

Now the rest. That thing is dumping everything into your prompt all attrs of every device that is in an assigned area. While it kinda works brute force style. You’re really going to have to work on that. Long term. First figure out if its your prompt template or the integration.

Ah great, OK: if I dump that into the Template box in Developer tools the Result box says:

TypeError: Type is not JSON serializable: LoggingUndefined

…which is a bit opaque: certainly there is nothing in the text I pasted in about “Logging”…? Is “Logging” something I need to define?

EDIT: if I dump the default template from https://github.com/acon96/home-llm/blob/d44152413d2b8ca7d2958e39f521bc0c3a4264b5/docs/Model%20Prompting.md into the same box it gives the same error, so I guess the error is in one of the devices or whatever that is being brought in. I guess I need a way to find out which one.

The short version. You’re gonna need to work on that template.

I can’t tell you exactly where it it but I Bet it’s that for loop in line 5,6,7

What thats doing is unwinding all your devices and reading them out into a json dict for your agent to be able to read (again problem if yih have a lot of devices)

But… worse it’s also just raw dumping the attributes too. (that +device. Attributes) I bet it’s running into a datetime it can’t serialize (very common, ran into the same when I was building my inspect tool) and boom.

Short version that statement needs to be rewritten to guard against a return it cannot decode (your error)

Understood, thanks for your help. I was kinda hoping that using the example would be the thing; will try to understand what the devil the things in the template actually refer to…

EDIT: the line that triggers the problem appears to be:

Tools: {{ tools | to_json }}

The problem is that your tools data cannot be turned into json. Post the results of that string.

Unless he has something setting it upstream that should resolve to None | to_json, in my editor it is showing undefined but warns and is non blocking…

But the error is coming from to_json trying to serialize an object that json doesn’t know. That object is:

1 Like

The variable tools turns out to not be defined when I run the script under the Developer Tools template. Since it is a part of the example system prompt template provided for home-llm (home-llm/docs/Model Prompting.md at d44152413d2b8ca7d2958e39f521bc0c3a4264b5 · acon96/home-llm · GitHub) DeepSeek suggests that it is “dynamically generated by the Assist API from my exposed entities when actively processing a request from the voice assistant”, which means that it is not possible to debug the prompt under Developer Tools.

Any other suggestions on how to debug the cause of the problem Value should be a list (or is DeepSeek hallucinating)?

EDIT: seems like others are having the same issue:

…but there is no clear resolution. Hmph.

EDIT TO THE EDIT: I’ve reported it to home-llm also in case they have any clues:

FYI, I made a new Assist to mess about with, in which I changed various things (including entirely deleting the text in the system prompt box under the Conversation agent settings). After finding somethingorother that allowed the Submit button to work, deleting stuff and selecting random things, I found out that the Conversation agent is global, not Assist-specific, so I had accidentally destroyed my original [working] setup.

However, I had a copy of the relevant bits, reinstated them on my original [working-but-not-saveable] Assist and now it works.

Unh?

Shirley there must be a way to debug an error like this in-situ, for when this happens again? Some logging, an intermediate file left behind as part of the process, something to tell me what the devil is being objected-to in this muttly-layered world? Feels like there are too many layers trying to protect me and, when one of them doesn’t work, I’m left high and dry.