rohitsar567 Claude Opus 4.7 (1M context) commited on
Commit
f068094
·
1 Parent(s): 531dfbd

fix(orchestrator): KI-094 — extractor cannot clear a filled profile field

Browse files

LLM profile_extractor periodically returned {"name": null, "age": null, ...}
for turns where the user didn't restate fields. The orchestrator was passing
those nulls through to session.update_profile_field, OVERWRITING captured
values mid-session. next_question(profile) then returned the cleared slot
and the bot re-asked it, breaking fact-find progression.

KI-091 already skips the extractor on fact-find turns; KI-094 closes the
same hole for QA-mode turns where the extractor still runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. backend/orchestrator.py +8 -0
backend/orchestrator.py CHANGED
@@ -549,6 +549,14 @@ async def handle_turn(
549
  extracted = await extract_profile_updates(user_text, session.profile)
550
  if extracted:
551
  for field_name, new_value in extracted.items():
 
 
 
 
 
 
 
 
552
  if field_name == "health_conditions":
553
  existing = list(session.profile.health_conditions or [])
554
  existing_lower = {c.lower() for c in existing if c}
 
549
  extracted = await extract_profile_updates(user_text, session.profile)
550
  if extracted:
551
  for field_name, new_value in extracted.items():
552
+ # KI-094 — never let the LLM extractor CLEAR a filled field.
553
+ # The extractor LLM periodically returns {"name": null} for
554
+ # turns where the user didn't restate the name; without this
555
+ # guard `update_profile_field("name", None)` overwrites the
556
+ # captured value mid-session, sending next_question() back to
557
+ # the name slot and breaking fact-find progression.
558
+ if new_value in (None, "", []):
559
+ continue
560
  if field_name == "health_conditions":
561
  existing = list(session.profile.health_conditions or [])
562
  existing_lower = {c.lower() for c in existing if c}