fix(xai): match id-less delete acks to the oldest pending delete - #7122
Draft
Speediing wants to merge 2 commits into
Draft
fix(xai): match id-less delete acks to the oldest pending delete#7122Speediing wants to merge 2 commits into
Speediing wants to merge 2 commits into
Conversation
xAI acknowledges conversation.item.delete with item_id "". The plugin maps that ack to the first future in _item_delete_future, which can be one the server already rejected by event id, so the ack removes the wrong item from the mirror and the real delete waits out update_chat_ctx's 5s timeout. Co-authored-by: Jason Wiker <jason.wiker@gmail.com>
xAI's conversation.item.deleted carries item_id "". The shim picked the first key of _item_delete_future, but a delete the server rejected by event id is already settled and still sits there until update_chat_ctx's finally. The ack then removed the wrong item from the remote mirror and left the real delete pending until the 5s update_chat_ctx timeout. Skip settled futures. Co-authored-by: Jason Wiker <jason.wiker@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
xAI's realtime API acknowledges
conversation.item.deletewith an emptyitem_id. The plugin mapped that ack to the first pending delete future, which can already be a settled (rejected) one. The real delete then sat untilupdate_chat_ctx's 5s timeout, which looks like a mid-session hang.This PR matches an id-less delete ack to the oldest unsettled pending delete instead.
Changes
item_iddelete ackTest plan
tests/test_realtime/test_xai_realtime_model.pyupdate_chat_ctxunder load with xAI realtimeRelated findings (no code change)
These came up while digging the hang. Separate from the delete-ack bug:
$refin tool schemas — Both OpenAI and xAI plugins forward$ref/$defsas-is. A live probe against xAI accepted a mid-session tools update with nested$refand still produced a response. Field reports that stripping$refhelps may be conflating this with theupdate_chat_ctxtimeout above.Long-lived sessions — OpenAI realtime defaults
max_session_durationto 20 minutes (websocket recycle). xAI defaults it toNone. Callers can setmax_session_duration=20*60today; changing the xAI default is a possible follow-up.Context / item IDs — xAI often omits
item_id/previous_item_idon conversation item events, so the plugin has to guess. Wrong guesses desync the mirror. Needs better IDs from xAI (see also xAI realtime: an interruption desyncs the local chat context, then every later item is dropped (unrecoverable) #6391). This PR only fixes one wrong-guess path on delete acks.