fix(api): don't re-persist user turn on empty-response retry (#4079)
The non-streaming retry called process_direct again with the same content, persisting a duplicate user turn. Pass persist_user_message=False so the retry recovers a response without re-recording the user message.
This commit is contained in:
@@ -22,6 +22,7 @@ INTERNAL_CONTINUATION_META = "_internal_continuation"
|
||||
INTERNAL_CONTINUATION_KIND_META = "_internal_continuation_kind"
|
||||
INTERNAL_CONTINUATION_PENDING_META = "_internal_continuation_pending"
|
||||
INTERNAL_CONTINUATION_RUN_STARTED_AT_META = "_internal_continuation_run_started_at"
|
||||
SKIP_USER_PERSIST_META = "_skip_user_persist"
|
||||
|
||||
_GOAL_CONTINUATION_KIND = "sustained_goal"
|
||||
_GOAL_CONTINUATION_SENDER = "system:continuation"
|
||||
@@ -59,6 +60,8 @@ def internal_continuation_run_started_at(metadata: Mapping[str, Any] | None) ->
|
||||
|
||||
def should_persist_user_message(metadata: Mapping[str, Any] | None) -> bool:
|
||||
"""Return whether this inbound message should be persisted as user input."""
|
||||
if metadata and metadata.get(SKIP_USER_PERSIST_META) is True:
|
||||
return False
|
||||
return not internal_continuation_inbound(metadata)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user