chore: address review notes — dedup comment and 409-path clarification

This commit is contained in:
Arsh Kumar Singh 2026-05-20 19:57:20 +00:00
parent d385db69d5
commit 2253cf5a32
No known key found for this signature in database
2 changed files with 8 additions and 0 deletions

View file

@ -122,6 +122,11 @@ def submit_pending(session_key: str, data: dict) -> _ClarifyEntry:
== list(data.get("choices_offered") or []) == list(data.get("choices_offered") or [])
): ):
entry = last entry = last
# Dedup re-uses the existing entry with its original clarify_id.
# If a future caller pre-populates clarify_id in data, it is
# silently discarded here — the original entry's id wins.
# Today no caller sets clarify_id (it's generated by __init__),
# so this is a non-issue.
cb = _gateway_notify_cbs.get(session_key) cb = _gateway_notify_cbs.get(session_key)
# Keep _pending aligned to the oldest unresolved entry. # Keep _pending aligned to the oldest unresolved entry.
_pending[session_key] = gw_queue[0].data _pending[session_key] = gw_queue[0].data

View file

@ -9080,6 +9080,9 @@ def _handle_clarify_respond(handler, body):
ok = _resolve_clarify_legacy(sid, clarify_id, response) ok = _resolve_clarify_legacy(sid, clarify_id, response)
if not ok: if not ok:
# Both the runtime adapter and legacy paths set ok=False for
# stale/expired/wrong-session responses. The 409 status applies
# uniformly regardless of which path resolved the clarify request.
return j(handler, { return j(handler, {
"ok": False, "ok": False,
"error": "Clarification prompt expired or not found. The agent may have already proceeded.", "error": "Clarification prompt expired or not found. The agent may have already proceeded.",