Repository navigation
fix(workspace): a voice call sits where it happened, and the agent's next typed turn knows what was said (#2694) - #2697
Conversation
…next typed turn knows what was said (#2694) Two defects, one per side of the portal messages table. The read side — the window, not the sort. The stored order was never wrong: both writers stamp the same ISO-Z microsecond format and the read orders by it. `get_history` returned the newest 100 ROWS, and a 30-minute voice call is ~180 rows, so one call filled the window, every typed turn before it fell off, and the call block — anchored at the call's first row in the window — rendered as the head of the thread. The window is now counted in TYPED turns (`get_portal_thread_window`: the newest 100 for the endpoint, 20 for the cold replay), the spoken rows of the calls among them ride along whole, and a row ceiling (600, the newest survive) reports itself as `truncated` so the chat can say "Earlier messages in this chat aren't shown" instead of silently re-creating the symptom. Both statements order by `created_at DESC, id DESC` (the uuid tiebreak is stable, not chronological); verified on SQLite and PostgreSQL. The reply poll pays for none of it. It now reads `?limit=N` (1–50, row semantics) and finds the reply by identity — the newest typed assistant row's id — instead of by a count that a shifting window breaks; a spoken reply is never the typed one. The turn side — what the live session never heard. A resumed turn dropped the history replay (ent#358), which was right for typed turns and wrong for spoken ones: the voice provider wrote the call straight into the thread and the agent's own session was not there. A resumed turn is now prefixed with the delta — the platform-written rows since the agent's newest typed reply (`get_platform_rows_since_last_reply` → `_format_voice_delta`; the assistant cursor survives a failed typed turn). The cold replay (`_format_history_context`, rewritten) renders the same rows in the same form and the delta is never added to it, so a cold retry cannot double-send. One renderer for both: spoken rows labelled, the platform's own rows as bracketed markers (never `You:`), whitespace collapsed so a transcript line cannot forge a labelled line, and ONE total spoken budget (24k chars — a whole 30-minute call fits) trimmed oldest-first across calls with every cut named. The 12-rows-per-call counter is gone. No reply lands mid-call, in both directions: a call is refused (409) while a typed reply is in flight, and a typed turn is refused (409, unbilled, retryable) while a call is on, through a live-call marker set at call start and cleared by the bridge's close and the REST stop. Both reads fail open. Tests: tests/unit/test_2694_voice_thread_window.py (real tables + real writers), tests/unit/test_2694_voice_delta_context.py (through the real portal_chat), frontend specs for the render order and the identity-based reply picker; the ent#534 budget test and the #2320 raise-site table updated. Docs: workspace-voice-conversation.md (new section), requirements FR-3b, the workspace/execution area files, two learnings entries, a CSO diff report. Fixes #2694 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01F2QYRXnk9XT8aFreKyk6na
|
merge-train 2026-09-10 (evening run): riding. No criticals; 173 backend + 119 frontend tests pass on the head, every new symbol has a live consumer, and the body's One finding recorded as a follow-up rather than blocking, because the marker TTL already bounds it: #2700 — the live-call marker is set in Also noted: the whole |
…l-thread-order # Conflicts: # docs/memory/learnings.md # tests/registry.json
trinity-ability
left a comment
There was a problem hiding this comment.
merge-train: batch validated on train/20260911-0925 (#2701)
Summary
db.get_portal_thread_window), the calls among them ride along whole, and a row ceiling reports itself astruncated(the chat says "Earlier messages in this chat aren't shown" instead of silently starting mid-call). The stored order was never wrong — reproduced with the real writers and verified on SQLite and PostgreSQL.GET …/history?limit=N(1–50, row semantics) is the poll's narrow read;replyFromHistoryfinds the reply by identity (the newest typed reply's id), not by a count that a shifting window breaks. A spoken reply is never the typed one.get_platform_rows_since_last_reply→_format_voice_delta); the cold replay (_format_history_context, rewritten) carries the same rows in the same form and the delta is never added to it (no double-send on a cold retry). One renderer: spoken rows labelled, the call's label as a bracketed platform marker (neverYou:), whitespace collapsed so a transcript line cannot forge a labelled line, one total 24k-char spoken budget (a whole 30-minute call fits) trimmed oldest-first with every cut named. The 12-rows-per-call counter is gone.voice_call_activecategory) while a call is on, via a live-call marker set at call start and cleared by the bridge's close and the REST stop. Both reads fail open on a Redis outage.Changes
src/backend/client_portal/db.py—ThreadWindow,get_portal_thread_window,get_platform_rows_since_last_reply,PORTAL_HISTORY_ROW_CEILING;idtiebreak on the existing read.src/backend/client_portal/service.py—_context_lines/_format_history_context(rewritten) /_format_voice_delta,_SPOKEN_CONTEXT_MAX_CHARS,VOICE_DELTA_HEADER;portal_chatreads the window + the delta before persisting;get_history(limit=)+truncated;_refuse_turn_during_voice_callin both turn entries;voice_call_activecategory.src/backend/client_portal/voice.py— 409 over an in-flight reply; live-call marker helpers, set at call start.src/backend/routers/voice.py— marker cleared in the bridge'sfinallyand in/stop.src/backend/client_portal/router.py,models.py— boundedlimitquery param;PortalHistory.truncated.src/frontend/src/components/portal/portalUtils.js—latestTypedReply,replyBaseline, identity-basedreplyFromHistory.PortalConversation.vue— narrow poll read, identity baseline (also on reattach), truncated line (shares one class with the ent#523 system line — raw-colour ratchet flat).stores/clientPortal.js—fetchHistory(…, { limit })+truncated.workspace-voice-conversation.md(new section),workspace-absorbs-session.md,execution.md,workspace.md, requirementspublic-access.mdFR-3b +runtimes.md, twolearnings.mdentries,docs/security-reports/cso-diff-2026-09-10-2694-*(no findings at the gate).Test Plan
tests/unit/test_2694_voice_thread_window.py— real tables + real writers: typed→long call→typed→call→typed reads back as the timeline; window counts typed rows; ceiling keeps the newest and reports; dedup read keeps row semantics; tie determinism; delta cursor survives a failed typed turn;get_historywindow/narrow reads; routelimitbounds.tests/unit/test_2694_voice_delta_context.py— through the realportal_chat: resumed turn carries the call; cold turn carries it in the replay with no delta block; delta read before persist; read failure never blocks; budget across calls; label neverYou:; newline collapse; 409 over an in-flight reply after the uniform 404; 409 typed turn during a call; marker set/cleared/fails open.portalVoiceMode.spec.js(render order typed→call→typed→call→typed, truncated line, narrow poll),portalReplyRateable.spec.js(identity rule, window shift, spoken never mistaken, post-call null-id baseline).unit15103 passed (the only failure is the pre-existingtest_1920guard on the enterprise submodule, unrelated); frontendnpm run test:unit2660 passed, raw-colour ratchet flat.Reviewed by: /autoplan (strategy + engineering subagents) + /gemini-critic, /review (structural), /cso --diff. Root-cause premise (the row window) confirmed by the reporter at the plan gate.
Fixes #2694
🤖 Generated with Claude Code
https://claude.ai/code/session_01F2QYRXnk9XT8aFreKyk6na