Skip to content

v1.1.0 - Gemma3 Think Block Fix

Choose a tag to compare

@cronus42 cronus42 released this 29 Dec 20:57

Ollama Conversation Agent v1.1.0

🎯 Overview

This release fixes a critical issue where the Gemma3 model was outputting raw <think> blocks instead of user-facing responses when controlling devices.

🐛 Bug Fixes

Gemma3 Think Block Issue

Problem: When using Gemma3, device control responses showed internal reasoning blocks like:

<think> Alright, the user just turned off the desk lamp. Let me make sure I followed all the instructions...

Solution: Implemented comprehensive filtering and fallback mechanisms:

  • Enhanced regex patterns to handle both complete and unclosed <think> tags
  • Added intelligent fallback response generation when filtering results in empty text
  • Updated system prompt to explicitly prohibit <think> tags in model outputs
  • Added comprehensive debug logging for troubleshooting

✨ New Features

  • Smart Fallback Responses: When model outputs only reasoning, automatically generates natural confirmations (e.g., "Done! I've turned off light.desk_lamp.")
  • Enhanced Debug Logging: Track response filtering operations and model behavior
  • Improved System Prompt: Clearer instructions for models on response formatting

🔧 Technical Changes

Modified Files

  • conversation.py: Enhanced _filter_think_blocks() function with dual regex patterns and fallback logic
  • manifest.json: Version bump to 1.1.0
  • CHANGELOG.md: Comprehensive changelog with all changes

New Files

  • FIX_SUMMARY.md: Technical details of the fix implementation
  • TESTING.md: Deployment and testing guide

📦 Installation

Method 1: HACS (Recommended)

  1. Open HACS in Home Assistant
  2. Go to Integrations
  3. Search for "Ollama Conversation"
  4. Click Update (if already installed) or Install

Method 2: Manual Installation

  1. Download ollama-conversation-v1.1.0.zip
  2. Extract to your Home Assistant custom_components directory:
    unzip ollama-conversation-v1.1.0.zip -d /config/custom_components/
  3. Restart Home Assistant

Method 3: Direct Copy

cd /path/to/homeassistant-ollama-agent
scp -r custom_components/ollama_conversation your-ha-server:/config/custom_components/

🧪 Testing

After installation, test with these commands:

  1. Light Control: "Turn off the desk lamp"
  2. Climate Control: "Set the bedroom to 72 degrees"
  3. Brightness: "Turn on the kitchen light to 50%"

Expected Results:

  • ✅ No <think> tags visible to users
  • ✅ Natural, concise confirmations
  • ✅ Proper device control execution

🐞 Debug Mode

To enable detailed logging, add to configuration.yaml:

logger:
  default: info
  logs:
    custom_components.ollama_conversation: debug

🔗 Links

📋 Full Changelog

See CHANGELOG.md for complete details.

🙏 Credits

Developed by goose (Block's AI agent) as part of the open-source Goose project.


Compatibility: Home Assistant 2024.x or later, Ollama with function-calling support
Supported Models: Gemma3, function-gemma, and other Ollama models with tool calling