<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nabeera Khan</title>
    <description>The latest articles on DEV Community by Nabeera Khan (@nabeerak).</description>
    <link>https://dev.to/nabeerak</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3828072%2Fe0d2a997-fb86-491d-98a5-963ac700497b.png</url>
      <title>DEV Community: Nabeera Khan</title>
      <link>https://dev.to/nabeerak</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nabeerak"/>
    <language>en</language>
    <item>
      <title>Why I Built an AI with a Spine: Anchoring Behavioral Integrity in the Gemini Live API</title>
      <dc:creator>Nabeera Khan</dc:creator>
      <pubDate>Mon, 16 Mar 2026 23:43:21 +0000</pubDate>
      <link>https://dev.to/nabeerak/title-why-i-built-an-ai-with-a-spine-anchoring-behavioral-integrity-in-the-gemini-live-api-5fan</link>
      <guid>https://dev.to/nabeerak/title-why-i-built-an-ai-with-a-spine-anchoring-behavioral-integrity-in-the-gemini-live-api-5fan</guid>
      <description>&lt;h1&gt;
  
  
  Building Willow: An AI That Pushes Back
&lt;/h1&gt;

&lt;p&gt;I created this content for the purposes of entering the Gemini&lt;br&gt;&lt;br&gt;
  Live Agent Challenge.&lt;/p&gt;

&lt;p&gt;Most voice AI agents are designed to be "people pleasers." If&lt;br&gt;
  you insult them, they apologize. If you talk over them, they&lt;br&gt;
  stop. If you gaslight them, they politely agree.&lt;/p&gt;

&lt;p&gt;When I set out to build &lt;strong&gt;Willow&lt;/strong&gt; for the Gemini Live Agent&lt;br&gt;
  Challenge, I wanted to solve a structural problem: absolute&lt;br&gt;
  subservience. I wanted to build an AI that felt like a peer —&lt;br&gt;
  someone with boundaries, a memory, and the mathematical&lt;br&gt;
  integrity to push back when a line is crossed.&lt;/p&gt;

&lt;p&gt;## The Architecture of "Warm but Sharp"&lt;/p&gt;

&lt;p&gt;Willow isn't just a prompt-wrapped bot. Her personality is&lt;br&gt;
  anchored in a deterministic behavioral state called the&lt;br&gt;
  &lt;strong&gt;m-value&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I decoupled her "reflexes" from her "conscious thought" using a&lt;br&gt;
  4-Tier Engine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tier 1 (Reflex):&lt;/strong&gt; Immediate tone-mirrored openers in &amp;lt;50ms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tier 2 (Metabolism):&lt;/strong&gt; A 5ms heuristic guess of the user's
intent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tier 3 (Conscious):&lt;/strong&gt; Deep analysis using Gemini to detect
manipulation tactics like gaslighting or deflection.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tier 4 (Sovereign):&lt;/strong&gt; A deterministic "Truth Gate" that
cancels the audio stream mid-sentence if a core fact is
contradicted.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;## Math over Prompts&lt;/p&gt;

&lt;p&gt;I learned early on that you can't tell an LLM to "be assertive"&lt;br&gt;
  and expect it to last. Prompts drift. Instead, Willow's behavior&lt;br&gt;
   is mathematical:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
text
  a(n+1) = a(n) + d + m

  If the m-value drops below a certain floor, her code physically
  restricts her to 20-word sentences and flattens her vocal pitch.

  By using the google-genai SDK and the
  gemini-2.5-flash-native-audio-preview model, I was able to
  inject behavioral context between turns as synthetic [SYS]
  messages. This allowed Willow to switch voices — from the warm
  Zephyr to the cold, precise Aoede — without the latency of
  reinitializing the session.

  The Dignity Floor

  The most rewarding part of this build was the Sovereign Spike.
  If a user tries to rewrite Willow's identity, the system
  validates the input against a local sovereign_truths.json file
  through a triple gate:

  1. Transcription confidence check
  2. Keyword match
  3. Semantic similarity

  The result isn't a canned safety filter — it's targeted,
  deterministic boundary enforcement.

  What I Learned

  Building this as a solo developer in Pakistan was a race against
   time, but it taught me one thing: the future of AI isn't just
  about faster tokens or better voices. It's about presence.
  Peerhood requires friction, and friction requires a mathematical
   spine.

  Demo

  

  &lt;iframe src="https://www.youtube.com/embed/c0put8q_pV0"&gt;
  &lt;/iframe&gt;




  Source Code

  

&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Nabeerak" rel="noopener noreferrer"&gt;
        Nabeerak
      &lt;/a&gt; / &lt;a href="https://github.com/Nabeerak/willow" rel="noopener noreferrer"&gt;
        willow
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Willow: A behavioral voice agent with a mathematical spine, prioritizing sovereign peerhood 
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;
&lt;a rel="noopener noreferrer" href="https://github.com/Nabeerak/willow/willow-dashboard/public/logo.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FNabeerak%2Fwillow%2Fwillow-dashboard%2Fpublic%2Flogo.png" width="100" height="100"&gt;&lt;/a&gt; Willow&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Warm but Sharp.&lt;/strong&gt; An AI voice agent with a behavioral framework that adapts dynamically to conversational tone, detects psychological manipulation tactics, and enforces factual integrity with a deterministic Sovereign Truth layer.&lt;/p&gt;

&lt;p&gt;Built for the &lt;strong&gt;2026 Gemini Live Agent Challenge&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/c0put8q_pV0" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/bcbf064dd90494cdf6a72dc9ffca3af97577c212ad4d012bed0fd345f8fbeedc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f44656d6f2d596f75547562652d726564" alt="Demo Video"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Architecture Overview&lt;/h2&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/Nabeerak/willow/architecture.svg"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FNabeerak%2Fwillow%2Farchitecture.svg" alt="Willow Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;User voice input
        │
        ▼
┌──────────────────────────────────┐
│  Audio Capture (Browser)         │  Noise gate, adaptive buffer, preflight warmup
│  noise-gate-processor.js         │
│  audio_capture.js                │
└──────────────┬───────────────────┘
               │ WebSocket (binary audio + JSON control)
               ▼
┌──────────────────────────────────┐
│  WillowAgent  (src/main.py)      │
│                                  │
│  Tier 1: Reflex    &amp;lt;50ms         │  Tone mirroring, Warm but Sharp opener
│  Tier 2: Metabolism  &amp;lt;5ms        │  State formula aₙ₊₁ = aₙ + d + m
│  Tier 3: Conscious  &amp;lt;500ms       │  Thought Signature, tactic detection
│  Tier 4: Sovereign   &amp;lt;2s         │  Hard truth override (deterministic)
└──────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Prerequisites&lt;/h2&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Python 3.12+&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://aistudio.google.com/apikey" rel="nofollow noopener noreferrer"&gt;Gemini API key&lt;/a&gt; with access to &lt;code&gt;gemini-2.5-flash-native-audio-preview-12-2025&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Google Cloud SDK (for deployment only)&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Quick Start (Local)&lt;/h2&gt;…&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Nabeerak/willow" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;





&lt;p&gt;#GeminiLiveAgentChallenge #GoogleCloud #GeminiAI #BuildWithAI&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>geminiliveagentchallenge</category>
      <category>googlecloud</category>
      <category>ai</category>
      <category>python</category>
    </item>
  </channel>
</rss>
