HEL-879 rework materials: hatchling cache correction with the offline mem0ai wheel actually built from the fixed source (sha256 698284b6..., zero downloads/installs, no 3.10 mixing, recorded in release-artifacts.json), hel895 release doc §0 now separates the historical HEL-895/896 candidate from the current hel-879-assembly candidate and §4/§5 carry the v3 snapshot semantics, budget §6.2.4 amended - a sealed library is never reopened by raising total_requests (contradiction removed), runbook §3.3/3.5/3.6/4.4/4.5 corrected (bounded cleanup ledger replaces the unproven rooms-die-naturally claim; assistant_interim kind; real-but-default-off proactive seam; single-owner dual launcher), one comment-only correction in web/src/voice/session.ts removing the unproven server-auto-cleanup claim (no logic/style change; CSS and JS bundle hashes byte-stable), CG-011 + her incremental subtitles now have a real minimal backend seam (voice/seam.py + worker/llm_chat_api wiring, proactive default off) with the precise frontend interface and acceptance list in docs/rework/hel879/voice-seam-interfaces.md, real-SDK check extended to 10 items (worker callback path on real SpeechHandle/SpeechCreatedEvent; interim seam through real LLMStream) and re-run on .12 ALL PASS, handoff-HEL-879.json appended with the rework scope; regression at this head: pytest 341/341, ruff clean except 1 pre-existing error identical at 7f0a739, web typecheck 0 errors / lint 0 errors 1 pre-existing warning / vitest 88/88 / build passes (CSS index-BpZaybfD.css unchanged), voice chain 8/8, budget split 10/10, release offline R1-R7, http pagination 7/7, real-service browser 9/9 with zero non-loopback outbound, pinned-SDK 16/16+12/12+6/6+7/7+12/12, requirements checks 4/4 (origin/main and c121c42, each with/without handoff)

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
zonggong
2026-10-27 04:27:04 +08:00
co-authored by multica-agent
parent 78a5cfd8d7
commit 7c73d392b9
21 changed files with 567 additions and 94 deletions
+89 -3
View File
@@ -1,9 +1,14 @@
#!/usr/bin/env python3
"""Generate the HEL-877 real-SDK compatibility check for the .12 agent venv.
"""Generate the HEL-877/879 real-SDK compatibility check for the .12 agent venv.
Embeds the repo voice-module sources in a self-contained stdin script (no files
written to .12, no network, no service touched) and runs it with
/opt/voice-agent/agent/venv/bin/python (livekit-agents 1.8.8, livekit 1.1.20).
HEL-879 additions: the check drives the WORKER'S ACTUAL callback path with real
SpeechHandle/SpeechCreatedEvent objects — the handle-without-generation and
late-cleanup interleavings from the manager's independent review — and verifies
the assistant_interim delta seam through the real LLMStream machinery.
"""
from __future__ import annotations
@@ -12,7 +17,7 @@ import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
MODULES = ["chat_api_client", "receipt", "llm_chat_api"]
MODULES = ["chat_api_client", "receipt", "seam", "llm_chat_api"]
TEMPLATE = r'''
import asyncio, base64, json, sys, types
@@ -174,7 +179,88 @@ async def cancel_case():
asyncio.run(cancel_case())
ok.append("barge-in task cancel closes the in-flight HTTP stream immediately")
print("HEL-877 real-SDK check on livekit-agents", end=" ")
# 9. HEL-879: the worker's ACTUAL callback path on real SpeechHandle objects —
# the manager's two interleavings (handle without generation consuming the
# next turn's stream; late cleanup) plus interrupt/failure discard order,
# driven exactly like worker.entrypoint wires them.
from livekit.agents.voice.speech_handle import SpeechHandle
from livekit.agents.voice.events import SpeechCreatedEvent
receipt_mod = sys.modules["cybergril.voice.receipt"]
seam_mod = sys.modules["cybergril.voice.seam"]
async def worker_callback_path():
ledger = receipt_mod.TurnLedger()
done_futures = []
def on_speech_created(ev): # same guard + wiring as worker._on_speech_created
if not ev.user_initiated:
return
ledger.note_handle(ev.speech_handle, ev.created_at)
ev.speech_handle.add_done_callback(
lambda handle=ev.speech_handle: asyncio.get_running_loop().create_task(
after_playout(handle)
)
)
async def after_playout(handle): # same order as worker._after_playout
await handle.wait_for_playout()
failed = handle.exception() is not None
if handle.interrupted or failed:
ledger.discard(handle)
done_futures.append(("discarded", handle))
return
stream = ledger.stream_for(handle)
done_futures.append((stream, handle))
# H1: real handle, its turn is interrupted BEFORE any LLM stream starts.
h1 = SpeechHandle.create()
ev1 = SpeechCreatedEvent(user_initiated=True, source="generate_reply",
speech_handle=h1, created_at=1.0)
on_speech_created(ev1)
# H2: the next turn does start a generation (real handle + noted stream).
h2 = SpeechHandle.create()
ev2 = SpeechCreatedEvent(user_initiated=True, source="generate_reply",
speech_handle=h2, created_at=2.0)
on_speech_created(ev2)
s2 = types.SimpleNamespace(turn_id="new", receipt={"message_id": 2})
ledger.note_stream(s2, 2.1)
# Complete both handles through the SDK's own done-future machinery:
# H1 was interrupted (public interrupt()) before any generation started;
# H2 played out cleanly (done, no error).
h1.interrupt()
h1._mark_done()
h2._mark_done()
await asyncio.sleep(0.05) # let the scheduled done callbacks run
outcomes = {id(handle): (stream, handle) for stream, handle in done_futures}
assert outcomes[id(h1)][0] == "discarded", "interrupted handle must discard fail-closed"
assert outcomes[id(h2)][0] is s2, "the real turn must get its OWN stream"
# The manager's exact inputs, re-checked through stream_for directly:
assert ledger.stream_for(h1) is None
asyncio.run(worker_callback_path())
ok.append("worker callback path on real SpeechHandle/SpeechCreatedEvent: no-generation "
"handle discards, next turn keeps its own stream (explicit binding)")
# 10. HEL-879: assistant_interim seam through the REAL LLMStream machinery.
interim_payloads = []
async def interim_seam():
publisher = seam_mod.AssistantInterimPublisher(interim_payloads.append)
adapter = llm_mod.CyberGrillLLM("http://x", client=llm_mod.ChatApiClient(
"http://x", transport=httpx.MockTransport(handler)),
on_assistant_delta=publisher.feed)
publisher.reset()
stream = adapter.chat(chat_ctx=ctx)
async for _ in stream:
pass
assert [p["text"] for p in interim_payloads] == ["真实链路上", "真实链路上的一句完整回复。"]
assert all(p["kind"] == "assistant_interim" and p["role"] == "assistant"
for p in interim_payloads)
asyncio.run(interim_seam())
ok.append("assistant_interim seam: SSE deltas through real LLMStream feed her "
"incremental subtitle payloads (replace semantics, reset works)")
print("HEL-877/879 real-SDK check on livekit-agents", end=" ")
import importlib.metadata as md
print(md.version("livekit-agents") + ":", "ALL PASS")
for line in ok: