From 2253cf5a32b5dd63f2cf7078d3224cd5784b890b Mon Sep 17 00:00:00 2001 From: Arsh Kumar Singh Date: Wed, 20 May 2026 19:57:20 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20address=20review=20notes=20=E2=80=94?= =?UTF-8?q?=20dedup=20comment=20and=20409-path=20clarification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/clarify.py | 5 +++++ api/routes.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/api/clarify.py b/api/clarify.py index 87834009..8ad750ac 100644 --- a/api/clarify.py +++ b/api/clarify.py @@ -122,6 +122,11 @@ def submit_pending(session_key: str, data: dict) -> _ClarifyEntry: == list(data.get("choices_offered") or []) ): 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) # Keep _pending aligned to the oldest unresolved entry. _pending[session_key] = gw_queue[0].data diff --git a/api/routes.py b/api/routes.py index 5a523d19..af6599dc 100644 --- a/api/routes.py +++ b/api/routes.py @@ -9080,6 +9080,9 @@ def _handle_clarify_respond(handler, body): ok = _resolve_clarify_legacy(sid, clarify_id, response) 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, { "ok": False, "error": "Clarification prompt expired or not found. The agent may have already proceeded.",