feat(sprint6b-D): soft-insertion counter + message meta_json

- thread_state.soft_insertion_count: растёт при боковом ответе (soft_insertion=true
  в STATE_JSON без смены шага/слотов), сбрасывается при продвижении или handoff
- При soft_insertion_count >= 3 в системный промпт ветки добавляется SOFT_INSERTION_NUDGE
  — явная инструкция вернуть пациента к вопросу текущего шага
- state_machine.parse_branch_response читает флаг soft_insertion из STATE_JSON
- Новая колонка message.meta_json: {router_intent_code, served_intent_code, step_code, events}
  — хранит снимок маршрутизации каждой реплики ассистента
- «Песочница»: бейджи событий (sticky / soft_insertion / hard_handoff / resumed /
  routing_loop / validation_blocked) над каждым ответом ассистента

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
AR 15 M4
2026-04-25 20:24:22 +05:00
parent 3c71372ec8
commit 85c3ec0222
12 changed files with 257 additions and 13 deletions
+6 -1
View File
@@ -79,6 +79,7 @@ def parse_branch_response(text: str) -> dict:
state_after = data.get("state_after")
slots_updated = data.get("slots_updated", {})
soft_insertion = bool(data.get("soft_insertion", False))
if not isinstance(state_after, str) or not state_after:
return {
"visible_text": text[:state_match.start()].rstrip(),
@@ -92,7 +93,11 @@ def parse_branch_response(text: str) -> dict:
return {
"visible_text": text[:state_match.start()].rstrip(),
"intent_change": None,
"state_update": {"state_after": state_after, "slots_updated": slots_updated},
"state_update": {
"state_after": state_after,
"slots_updated": slots_updated,
"soft_insertion": soft_insertion,
},
"parse_error": None,
}