harsh-d commited on
Commit
07edabe
·
verified ·
1 Parent(s): 7e22091

Retry transient Groq generation faults; nudge PII collection

Browse files
Files changed (1) hide show
  1. tools.py +16 -1
tools.py CHANGED
@@ -321,11 +321,26 @@ def _handle_record_pii(inp: dict, state: SOPState, _fixtures: dict) -> str:
321
  field_name = inp["field_name"]
322
  value = inp["value"]
323
  state.collected_pii[field_name] = value
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  return json.dumps({
325
  "status": "recorded",
326
  "field": field_name,
327
- "total_fields": len(state.collected_pii),
328
  "fields_so_far": list(state.collected_pii.keys()),
 
329
  })
330
 
331
 
 
321
  field_name = inp["field_name"]
322
  value = inp["value"]
323
  state.collected_pii[field_name] = value
324
+ count = len(state.collected_pii)
325
+
326
+ # Smaller models record one field then stop, even when the caller supplied
327
+ # several at once. Restating the next action in the tool result — which the
328
+ # model reads immediately after each call — keeps it moving.
329
+ if count < 3:
330
+ next_step = (
331
+ f"Recorded. {3 - count} more matching field(s) needed. If the caller "
332
+ "mentioned ANY other identifying details in their message, call "
333
+ "record_pii for each of those now, before you reply to them."
334
+ )
335
+ else:
336
+ next_step = "Enough fields collected. Call verify_identity now."
337
+
338
  return json.dumps({
339
  "status": "recorded",
340
  "field": field_name,
341
+ "total_fields": count,
342
  "fields_so_far": list(state.collected_pii.keys()),
343
+ "next_step": next_step,
344
  })
345
 
346