Skip to content

fix(openai): delete trimmed empty audio items#5887

Open
he-yufeng wants to merge 1 commit into
livekit:mainfrom
he-yufeng:fix/realtime-delete-empty-audio-items
Open

fix(openai): delete trimmed empty audio items#5887
he-yufeng wants to merge 1 commit into
livekit:mainfrom
he-yufeng:fix/realtime-delete-empty-audio-items

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Summary

  • delete items explicitly trimmed out by update_chat_ctx(), even if the local copy has empty content
  • keep the empty-content guard for updates so unsynced audio/image items are not recreated
  • add a unit test for empty audio-like remote items being deleted from the OpenAI realtime context diff

Fixes #5886.

To verify

  • uv run pytest tests/test_realtime/test_openai_realtime_model.py -q
  • uv run ruff check livekit-plugins\livekit-plugins-openai\livekit\plugins\openai\realtime\realtime_model.py tests\test_realtime\test_openai_realtime_model.py
  • uv run ruff format --check livekit-plugins\livekit-plugins-openai\livekit\plugins\openai\realtime\realtime_model.py tests\test_realtime\test_openai_realtime_model.py
  • uv run python -m py_compile livekit-plugins\livekit-plugins-openai\livekit\plugins\openai\realtime\realtime_model.py tests\test_realtime\test_openai_realtime_model.py
  • git diff --check

Notes

  • uv run python scripts\check_types.py currently fails on Windows in livekit-agents\livekit\agents\cli\readchar.py because mypy sees POSIX termios/tty attributes as missing. The errors are outside this diff.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@theomonnom
Copy link
Copy Markdown
Member

@he-yufeng
Copy link
Copy Markdown
Contributor Author

Good catch. I kept that helper for the update path below: when an existing item id is recreated with different content, it still avoids recreating server-only audio/image items whose content was never synced down. This PR only changes the remove path so those trimmed empty items can be deleted from the server context.

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.

RealtimeSession.update_chat_ctx silently skips delete for audio items when input_audio_transcription=None → unbounded server context growth

2 participants