Skip to content

add execution status to FunctionCall and example for history compaction with openai realtime#5024

Open
longcw wants to merge 5 commits intomainfrom
longc/function-call-status-tracking
Open

add execution status to FunctionCall and example for history compaction with openai realtime#5024
longcw wants to merge 5 commits intomainfrom
longc/function-call-status-tracking

Conversation

@longcw
Copy link
Contributor

@longcw longcw commented Mar 6, 2026

fix #5021

@chenghao-mou chenghao-mou requested a review from a team March 6, 2026 07:13
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

@chenghao-mou chenghao-mou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Two nits.

extra={"item_id": item.id},
)
fnc_call = llm.FunctionCall(
id=item.id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the original system message is missing. I tried this example, and the agent started speaking Spanish after compaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants