From 1927badfc173c6d9a32deed9ca7776d987b2ea75 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 26 Sep 2026 09:07:36 +0200 Subject: Read controller batteries, stop the model guessing system facts - Game controllers report battery through their kernel driver, not BlueZ: bluetooth.sh falls back to the power supply named after the device address. - Asked for a VM's IP after a listing without one, the model made one up without calling a tool. The default system prompt now says facts about the user's computer, devices, accounts, mail, calendar or money come only from a tool, or it says it does not know. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 24 ++++++++++++++++++++++++ assistant.py | 5 ++++- examples/tools/bluetooth.sh | 13 +++++++++++-- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 9542840..395fed6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -369,6 +369,30 @@ file: the model fills parameters but cannot reach `mailctl tag` or confirmation before acting for exactly this reason. - These tools speak personal data (mail subjects, amounts) out loud. +### Bluetooth and VM tools, live test (2026-09-26) + +`bluetooth` (bluetoothctl show/devices/info) and `vms` (virsh list, +domstate, dominfo, domifaddr). Connecting devices and handling VMs are +phase 2. + +- A game controller (DualSense) reports no `Battery Percentage` through + BlueZ; its kernel driver (hid-playstation, same for hid-sony and + hid-nintendo) exposes a power supply named after the device address. + `bluetooth.sh` reads `/sys/class/power_supply/**/capacity` (and + `status` for charging) as a fallback. Live: "85 percento". +- `virsh domifaddr` with the default lease source is empty for a bridged + guest; `--source arp` (then `agent`) has the address. +- **The model invented a fact about the user's system.** After listing + the VMs, "what is buildsystem's IP?" got a made-up private address with + no tool call: the previous tool output had no IP and the model filled + the gap. Fix in the default system prompt: facts about the user's + computer, devices, accounts, mail, calendar or money come only from a + tool; if none can tell, say so, never guess. Same sequence after the + fix: it called `vms(name)` and read the real address. A custom + `system` in config.toml drops this rule unless it is copied in. +- Whisper wrote "build system" as two words; the model mapped it to the + VM name `buildsystem` without help. + ### Barge-in (2026-09-26) A button press cuts the current reply. A global `turn` counter goes up on diff --git a/assistant.py b/assistant.py index 3bd4b20..4ea8113 100644 --- a/assistant.py +++ b/assistant.py @@ -46,7 +46,10 @@ DEFAULTS = { "llm": "http://localhost:8181/v1", "system": ("You are a voice assistant. Your replies are spoken aloud, so answer " "briefly in plain sentences: no markdown, no lists, no emoji. " - "Reply in the language the user speaks, Italian or English."), + "Reply in the language the user speaks, Italian or English. " + "Facts about the user's computer, devices, accounts, mail, calendar " + "or money come only from a tool: call one, and if none can tell, " + "say you do not know. Never guess them."), "tool_rounds": 3, "whisper": {"model": "/data/voice-models/whisper/ggml-large-v3-turbo-q5_0.bin", "device": 0, "port": 8182}, diff --git a/examples/tools/bluetooth.sh b/examples/tools/bluetooth.sh index a3af0f9..c00c853 100755 --- a/examples/tools/bluetooth.sh +++ b/examples/tools/bluetooth.sh @@ -16,7 +16,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # bluetooth.sh: whether bluetooth is on, the connected devices with their -# kind (BlueZ icon name) and battery when the device reports one, and the +# kind (BlueZ icon name) and battery when it is known, and the # paired devices that are not connected. Only show, devices and info run # here: nothing connects, pairs or scans. @@ -35,7 +35,16 @@ while read -r _ mac _; do if grep -q $'^\tConnected: yes' <<<"$info"; then kind=$(sed -n 's/^\tIcon: //p' <<<"$info") battery=$(sed -n 's/^\tBattery Percentage: .*(\([0-9]*\))$/\1/p' <<<"$info") - echo "connected: $alias (${kind:-unknown kind}${battery:+, battery $battery%})" + # Game controllers report it through their kernel driver instead + # (hid-playstation, hid-sony, hid-nintendo): a power supply named + # after the device's address. + charging="" + for supply in /sys/class/power_supply/*"${mac,,}"*; do + [ -r "$supply/capacity" ] || continue + battery=$(<"$supply/capacity") + [ "$(cat "$supply/status" 2>/dev/null)" = Charging ] && charging=", charging" + done + echo "connected: $alias (${kind:-unknown kind}${battery:+, battery $battery%}$charging)" connected=$((connected + 1)) else others+=("$alias") -- cgit v1.2.3