Friday's Party: Creating a Private, Agentic AI using Voice Assistant tools

Ninja? don’t you think you’re being a bit melodramatic here?

Who? Me?

Not at all. Because this is how we get to realize Agentic.

First we need to discuss what this context bloat has been leading to since day 1…

Attention

If you want to read, it’s all there. In the paper, the godfathers of the modern transformer talk about self-attention and multi-head attention. In short.

YOU CAN’T KEEP TRACK OF EVERYTHING

heck if you’ve ever participated in any kind of psych eval one of the thigs they do is see how many things and sequences we can keep track of before it all starts breaking down. And we’ve not been nice to poor Friday. C’mon - I crammed a 200000 token prompt so full it broke and asked her not to forget stuff? HA!

Total transparency, I MIGHT have known some of this ahead of time - and why I bloated the prompt in the first place. I had seen this: GitHub - allenporter/home-assistant-summary-agent: A Home Assistant Conversation Agent that summarizes the state of the Home The fact he bothered to do this leads to an understanding that we need to get lots of data into the AI in SUPPER SUMMARY fashion fast.

( BTW Props to Mr. Porter - he’s the code owner for the MCP Client /Server integrations, I think we’re going to be hearing a lot more from MCP but for now it’s a heavy lift.)

So last post we see how IMMEDIATE relief of this problem comes from clearing things.

Refinements from v.1 (Yes, Sunday)

  1. The summarizer now drops a component level summary one for the system at large and one each for each kung fu component.

This enables us to run summarization of each system independently and we can even auto summarize things that dont need AI interpretation - conserving tokens.

Want to run energy monitoring once daily and the upcoming tasks summary hourly? Yup.

  1. Template driven
    The summarizer template is pulled from a sensor that’s easy to update.

  2. Template Editor Script.
    Tell Friday about the template, Tell her how to edit it, tell her what edit to make.

Which now updates the template - which generates a new summarization on next summarizer run

  1. aaaaand… The NINJA2 Scheduler
    Tell Friday she can pick any 5 nonessential components, remind her to look at the schedule, the calendar, work/school what’s coming up in the next hour and then inform HERSELF which components should load for the next XX minutes (currently 60)

out pops a nice concise list pf components sooooo.

I hijack the existing Kung Fu loader and inject Friday’s suggested list of switches. Because this is filtered through what’s on - it has the net effect of… Adding to anything I deem CRITICAL and she can’t add anything that’s not turned on (because that filter happens later)

I also extra wrapped stuff with more to_json filters. (I’m starting to do this de-facto)

NINJA System Loader 2.0.0  Now MORE Ninja!
Starting ninja.foo...
{%- set ninja_summary_str = state_attr('sensor.ai_summary_cabinet', 'variables')['LAST_SUMMARY']['value']['ninja_autoloader'] %}
{%- set ninja_summary_list = ninja_summary_str | replace("'", '"') | from_json %}
{%- set suggested_ninja_switch_list = ninja_summary_list | map('slugify')
                         | map('regex_replace', '^', 'input_boolean.') 
                         | map('regex_replace', '$', '_master_switch') 
                         | list %}
Kung Fu Inventory:
{{ command_interpreter.render_cmd_window('', '', '~KUNGFU~', '') | to_json }}
Last NINJA Summary:
{{state_attr('sensor.ai_summary_cabinet', 'variables') | to_json}}
NINJA System Components:
  {%- set KungFu_Switches = expand(label_entities('NINJA System Service'))
    | selectattr ('domain' , 'eq' , 'input_boolean')
    | selectattr('state', 'eq', 'on')
    | map(attribute='entity_id')
    | list %}
  {%- set ninja_switches = (KungFu_Switches|list) + (suggested_ninja_switch_list|list) %}
  {%- set ninja_switches = ninja_switches|unique|list %}
  {%- for switch_entity_id in ninja_switches %}
  {%- set kungfu_component = switch_entity_id | replace('input_boolean.','') | replace('_master_switch','') %}
  {{ command_interpreter.kung_fu_detail(kungfu_component) |to_json }}
  {%- endfor %}
NINJA2_Mode: On

So every (time period X), SuperFriday loads up - sees the schedule and the template, which stuffs the prompt summary for the interactive version AND elects up to 5 kung fu components for the current time window… I load her list and system. And voila. Auto adaptation. She’s flexy. To check comprehension, I told her to leave a chat output window in the summary from the noninteractive prompt, and she uses it. :wink: She knows what’s up and what she’s doing there.

You want to make her change behavior - edit the template. Make her edit her OWN template. :slight_smile:

Buckle up - is about to get wild.