Skip to content

fix(realtime): restore function calls in updateHistory - #1672

Open
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/realtime-function-call-history-645
Open

fix(realtime): restore function calls in updateHistory#1672
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/realtime-function-call-history-645

Conversation

@sylvesterkaczmarek

@sylvesterkaczmarek sylvesterkaczmarek commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #645 by restoring function_call items when Realtime conversation history is populated through updateHistory.

New function-call history items are replayed with a stable synthetic call_id derived from the SDK history item ID. Completed calls replay their matching function_call_output, and Realtime API acknowledgements are correlated back into the local history projection.

Replay ownership is connection-scoped and fails closed around asynchronous server state:

  • unsupported in-place function-call edits and cross-type replacements are rejected before any server mutation;
  • mid-history function-call insertion, replay after a preceding item update, and repeated acknowledgement-pending replay are rejected before mutation;
  • completed call removal deletes the acknowledged output first and waits for conversation.item.deleted before deleting the call;
  • replay deletion state is advanced before normalized deletion acknowledgements are exposed to consumers;
  • asynchronous provider rejection of replay-owned public function outputs is correlated through client event IDs;
  • duplicate public outputs are rejected while an output is pending or after one has been acknowledged, preserving the acknowledged output item for later deletion;
  • mixed additions and non-function-call updates are recreated in target-history order;
  • repeated deletion while acknowledgement is pending is rejected;
  • replay ownership is cleared on synchronous send failure, transport close, and reconnect.

Existing non-function-call history behavior is preserved.

Test plan

Focused regression coverage verifies:

  • replay with and without function output;
  • echoed call/output projection into local history;
  • late/stale echo handling across reconnects;
  • reconnect and close ownership cleanup;
  • synchronous send-failure cleanup;
  • rejection of in-place edits, cross-type replacements, mid-history insertion, replay after preceding item updates, repeated replay, and repeated removal without emitting partial server mutations;
  • output deletion acknowledgement before function-call deletion;
  • synchronous callbacks observe advanced deletion state;
  • asynchronous rejection of a public replay output releases pending output state;
  • an acknowledged replay output cannot be overwritten by a duplicate output attempt and remains deletable by its output item ID;
  • mixed replay additions and recreated message updates are emitted in newHistory order.

The branch is based directly on current main and collapsed to one signed-off commit.

Issue number

Fixes #645.

@changeset-bot

changeset-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 91a58cf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@openai/agents-realtime Patch
@openai/agents Patch
realtime-react-native Patch
@openai/agents-core Patch
@openai/agents-openai Patch
@openai/agents-extensions Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a26015a41b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated
@github-actions github-actions Bot added project and removed project labels Aug 14, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abf2d6be8b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts
@github-actions github-actions Bot added project and removed project labels Aug 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1bc3878627

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 796f83f560

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts
@seratch seratch mentioned this pull request Aug 15, 2026
@github-actions github-actions Bot added project and removed project labels Aug 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0fcd0289f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated
Comment thread .github/workflows/validate-review-fixes-1672.yml Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f2517a2cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agents-realtime/test/functionCallHistoryReplay.test.ts
Comment thread packages/agents-realtime/test/functionCallHistoryReplay.test.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9da23fc9c7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated
Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated
@github-actions github-actions Bot added project and removed project labels Aug 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91374c9921

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/finalize-1672.yml Outdated
@github-actions github-actions Bot added project and removed project labels Aug 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb57e854a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3eba11f3e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated
Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated
Comment thread .github/workflows/pr1672-apply.yml Outdated
@sylvesterkaczmarek
sylvesterkaczmarek force-pushed the fix/realtime-function-call-history-645 branch from 0f536e8 to da86590 Compare August 16, 2026 11:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f536e802c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts
Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated
@github-actions github-actions Bot removed the project label Aug 16, 2026
@sylvesterkaczmarek
sylvesterkaczmarek force-pushed the fix/realtime-function-call-history-645 branch from da86590 to 2ac0578 Compare August 16, 2026 11:12

Copy link
Copy Markdown
Contributor Author

Addressed the latest review on the current head (2ac0578). Function-call history mutations now fail closed before server events, replay ownership is cleared on send failure/close/reconnect, and completed call/output deletion is serialized through the output deletion acknowledgement before deleting the call. Added controlled interleaving regressions for mid-history insertion, in-place/cross-type replacement, repeated replay/removal, staged deletion, and ownership cleanup. Focused validation passed: 62 Realtime tests, Prettier, agents-core build, and agents-realtime build-check. The branch is now one signed-off commit on current main; upstream CI is awaiting repository authorization.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ac0578fc7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9892d26a92

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated
@sylvesterkaczmarek
sylvesterkaczmarek force-pushed the fix/realtime-function-call-history-645 branch from 9892d26 to 7478cd1 Compare August 16, 2026 12:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7478cd1269

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated
Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 537c676c4f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts Outdated
@sylvesterkaczmarek
sylvesterkaczmarek force-pushed the fix/realtime-function-call-history-645 branch from acec2d4 to 849b2fb Compare August 16, 2026 17:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 849b2fb5b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts
Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts
@sylvesterkaczmarek
sylvesterkaczmarek force-pushed the fix/realtime-function-call-history-645 branch from 8552d64 to 36f6331 Compare August 16, 2026 19:45

Copy link
Copy Markdown
Contributor Author

@seratch The requested asynchronous replay-ownership cases are now addressed on the current one-commit head (36f6331), including the two follow-up findings from the latest Codex review. All inline review threads are resolved and focused regression coverage is included. When convenient, could you please re-review the updated head?

@sylvesterkaczmarek
sylvesterkaczmarek force-pushed the fix/realtime-function-call-history-645 branch from 36f6331 to 4a3c2e7 Compare August 16, 2026 22:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a3c2e7a7a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/agents-realtime/src/openaiRealtimeBase.ts
@sylvesterkaczmarek
sylvesterkaczmarek force-pushed the fix/realtime-function-call-history-645 branch from 4a3c2e7 to 3d2ddec Compare August 16, 2026 23:34
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for adding function call items to conversation history via updateHistory

2 participants