feat(conversation): what is said in pieces is answered once, and a dropped answer stops the brain
Live 2026-11-19 every piece of one thought (pauses of 0.1-4.7 s) was answered on its own and the brain wrote each cancelled answer to its end, so the replies queued up to 35 s. - conversation: a speaker who goes on before their answer is heard (within call.continueMs, default 5 s) has the earlier request taken back (policy withdraw, not missed) and the joined text answered as one request; a stop still stops; no second earcon; partials prepare the joined text - voice worker: a reply cancelled while waiting is never started, a running one stops at the engine's next model or tool call (turn_state.cancel), and it uses up no turn, so a confirmation carried by the joined request does not lapse - specs: conversation.spec.md (Going on), voice_worker.spec.md, llm_contexts.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2376,6 +2376,9 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
_one_step_nudged = False
|
||||
|
||||
while turn < max_turns:
|
||||
if _turn_state.cancelled():
|
||||
debug_log("reply cancelled: no longer wanted", "planning")
|
||||
return None
|
||||
turn += 1
|
||||
debug_log(f"🔁 messages loop turn {turn}", "planning")
|
||||
print(f" 🔁 Turn {turn}/{max_turns}", flush=True)
|
||||
@@ -2840,7 +2843,10 @@ def run_reply_engine(db: "Database", cfg, tts: Optional[Any],
|
||||
messages.append({"role": "tool", "tool_call_id": tool_call_id, "content": f"You have already called {tool_name} {duplicate_tool_count} times. Please use the results from those calls to answer the user's question."})
|
||||
continue
|
||||
|
||||
# Execute tool
|
||||
# Execute tool (not for an answer that is no longer wanted: no actions on its behalf)
|
||||
if _turn_state.cancelled():
|
||||
debug_log("reply cancelled before a tool call", "planning")
|
||||
return None
|
||||
tools_started += 1
|
||||
result = run_tool_with_retries(
|
||||
db=db,
|
||||
|
||||
@@ -37,6 +37,9 @@ pc : Optional[object]
|
||||
trace : Optional[list]
|
||||
v2: where the engine writes down how it made this answer (history.spec.md, "Traces"): the
|
||||
tools it was given, the plan, the model's thinking and each tool call. None records nothing.
|
||||
cancel : Optional[callable]
|
||||
v2: true once the answer is no longer wanted (the asker went on talking, or a newer request or a
|
||||
stop took its place). The engine checks it before each model call and each tool call.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -58,6 +61,17 @@ def reset() -> None:
|
||||
_state.screen = None
|
||||
_state.pc = None
|
||||
_state.trace = None
|
||||
_state.cancel = None
|
||||
|
||||
|
||||
def set_cancel(check) -> None:
|
||||
_state.cancel = check
|
||||
|
||||
|
||||
def cancelled() -> bool:
|
||||
"""Whether this turn's answer is no longer wanted."""
|
||||
check = getattr(_state, "cancel", None)
|
||||
return bool(check and check())
|
||||
|
||||
|
||||
def set_trace(steps: Optional[list]) -> None:
|
||||
|
||||
Reference in New Issue
Block a user