fix: post_turn consumes pending meanwhile digests (T82.1)
Wire chat.services.prompt.consume_pending_meanwhile_digests into chat.web.turns.post_turn at the END of the handler, after scene-close detection and before the response broadcast. Without this call digests created by a meanwhile close stay pending forever — they surface in the next you-turn's prompt (via T65) but are never marked consumed, so they re-render on every subsequent turn. Idempotent: re-calling the helper produces zero events when nothing's pending. The T66 cross-feature note is updated to reflect the new wiring; the existing direct-helper test in test_phase3_integration.py is preserved as defensive coverage of the helper contract in isolation.
This commit is contained in:
+13
-1
@@ -64,7 +64,10 @@ from chat.services.event_promotion import promote_completed_event
|
||||
from chat.services.interjection import detect_interjection
|
||||
from chat.services.memory_write import record_turn_memory_for_present
|
||||
from chat.services.multi_state_update import compute_state_updates_for_present
|
||||
from chat.services.prompt import assemble_narrative_prompt
|
||||
from chat.services.prompt import (
|
||||
assemble_narrative_prompt,
|
||||
consume_pending_meanwhile_digests,
|
||||
)
|
||||
from chat.services.rewind import compute_rewind_preview, execute_rewind
|
||||
from chat.services.scene_close import detect_scene_close
|
||||
from chat.services.scene_summarize import apply_scene_close_summary
|
||||
@@ -886,6 +889,15 @@ async def post_turn(
|
||||
timeout_s=settings.classifier_timeout_s,
|
||||
)
|
||||
|
||||
# 9a. Consume any pending meanwhile digests now that the assistant_turn
|
||||
# (which surfaced them in its prompt via T65's helper) has landed. The
|
||||
# spec's "first you-turn AFTER meanwhile close consumes the digest"
|
||||
# semantics are preserved by running this AFTER scene-close detection
|
||||
# — anything pending right now belongs to the prompt we just answered,
|
||||
# so it's safe to mark consumed and the NEXT turn starts clean.
|
||||
# Idempotent: re-calling produces zero events when nothing's pending.
|
||||
consume_pending_meanwhile_digests(conn, chat_id)
|
||||
|
||||
# 10. Broadcast a JSON completion event (for JS consumers) and an HTML
|
||||
# fragment event (for HTMX SSE swap-into-timeline). One pair per
|
||||
# written assistant_turn so the timeline ends up with both the
|
||||
|
||||
Reference in New Issue
Block a user