feat(app): addressed calls follow who is in the voice channel

Alone with Jarvis, whatever the speaker says is answered without asking the judge. With others
present the judge is told how many people are in the channel and how many may call Jarvis: with
one other person most of what the speaker says counts as said to Jarvis (unclear is yes); with
more, or not known, the question is the group one it was before. Live 2026-11-16: alone in the
channel, questions without the wake word got no answer because the judge assumed a group.
Eval (qwen3:8b, pair cases): 3/7 before, 6/7 after; group cases unchanged.

Also: the protocol test fixture's brain takes the trace argument (the test failed since traces).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-16 15:43:10 +09:00
parent 80ce9281a3
commit 72518ca50e
14 changed files with 213 additions and 40 deletions

View File

@@ -37,8 +37,8 @@ class FakeBrain:
self.notes, self.notes_backend, self.screen = notes, notes_backend, screen
return self.answer(user, text)
def addressed(self, user, text, names):
self.calls.append(("addressed", user, text, names))
def addressed(self, user, text, names, people=None, callers=None):
self.calls.append(("addressed", user, text, names, people, callers))
return "jarvis" in text
def rank(self, candidates):
@@ -634,7 +634,7 @@ def test_addressed_and_rank_answer_from_the_brain(store):
async with connect(url) as ws:
await hello(ws)
await send(ws, type="addressed", id="q1", user="100", text="jarvis, lights off")
await send(ws, type="addressed", id="q2", user="100", text="did you see that")
await send(ws, type="addressed", id="q2", user="100", text="did you see that", people=3, callers=1)
await send(ws, type="rank", id="k1", candidates=[{"id": "7", "user": "100", "text": "a"},
{"id": "8", "user": "200", "text": "b"}])
got = {}
@@ -648,6 +648,9 @@ def test_addressed_and_rank_answer_from_the_brain(store):
assert got["q1"] == {"type": "addressed_result", "id": "q1", "addressed": True, "failed": False}
assert got["q2"]["addressed"] is False and got["q2"]["failed"] is False
assert got["k1"] == {"type": "rank_result", "id": "k1", "order": ["8", "7"], "failed": False}
# Who is in the channel reaches the judgement; an older app that does not say gets None.
rooms = {c[2]: c[4:] for c in brain.calls if c[0] == "addressed"}
assert rooms == {"jarvis, lights off": (None, None), "did you see that": (3, 1)}
@pytest.mark.unit
@@ -1552,3 +1555,16 @@ def test_a_screen_action_goes_to_the_app_for_the_asker_and_its_pictures_come_bac
assert results == [{"ok": True, "item": {"what": "모니터 2", "width": 1280, "height": 720, "parts": 1},
"images": [picture]}]
assert brain.screen is None # a scheduled task sees no screen
@pytest.mark.unit
def test_the_judgement_is_told_who_is_in_the_channel(monkeypatch):
import voice_worker.judges as judges
asked = []
monkeypatch.setattr(judges, "call_llm_direct", lambda b, m, system, u, **k: asked.append(system) or "yes")
for people, callers in ((None, None), (2, 2), (5, 1)):
judges.is_addressed("u", "m", ["자비스"], "x", people=people, callers=callers)
unknown, pair, group = asked
assert "Several people" in unknown and "anything unclear" in unknown, "an app that does not say: as before"
assert "one other person" in pair and "unclear, answer yes" in pair
assert "5 people" in group and "Only 1 of the 5" in group and "anything unclear" in group