add execution status to FunctionCall and example for history compaction with openai realtime#5024
add execution status to FunctionCall and example for history compaction with openai realtime#5024
Conversation
…on with openai realtime
| tail_items: list[llm.ChatItem] = [] | ||
| for item in self.realtime_llm_session.chat_ctx.items: | ||
| if item.created_at > last_updated_at or ( | ||
| item.type == "function_call" and item.status != "completed" |
There was a problem hiding this comment.
it's not a good ux to ask user to care about this, but I am not sure if it's a good idea to add the guard of inflight tool call into the update_chat_ctx. maybe create a new api for truncate operation for realtime session?
There was a problem hiding this comment.
To me, the biggest concern is that if you are unlucky with timing and another chat context update happens at the same time as a new function call arrives, you can see get the problem.
If we had a different method for sending precise context updates using the _update_chat_ctx_lock, that could be a solution to the problem as well. So long as the example also provides a way to update local contest without update_chat_ctx.
| extra={"item_id": item.id}, | ||
| ) | ||
| fnc_call = llm.FunctionCall( | ||
| id=item.id, |
There was a problem hiding this comment.
nit: use item_id for consistency
| compacted_history.items.extend(tail_items) | ||
| logger.info(f"keeping {len(tail_items)} items from realtime session") | ||
|
|
||
| await self.update_chat_ctx(compacted_history) |
There was a problem hiding this comment.
It seems that the original system message is missing. I tried this example, and the agent started speaking Spanish after compaction.
fix #5021