Skip to content

Add inworld router#530

Draft
maxkahan wants to merge 101 commits intochore/audio-processing-v2from
add-inworld-router
Draft

Add inworld router#530
maxkahan wants to merge 101 commits intochore/audio-processing-v2from
add-inworld-router

Conversation

@maxkahan
Copy link
Copy Markdown
Contributor

@maxkahan maxkahan commented May 5, 2026

This pull request introduces asynchronous backend persistence for Stream Chat message syncing in the StreamConversation class, improving latency for voice and LLM-driven pipelines by dispatching REST calls as background tasks. It also ensures test and shutdown reliability by allowing callers to await completion of all in-flight syncs. Additionally, the changes update tests to await these background tasks and improve error handling and documentation.

Asynchronous backend persistence and ordering:

  • Refactored StreamConversation to dispatch Stream Chat syncs as fire-and-forget background tasks, serializing them with an asyncio.Lock to preserve message ordering and reduce latency on the critical path. Added a wait_for_pending_syncs() method to allow draining of in-flight tasks during tests and shutdown. [1] [2] [3] [4]
  • Updated the agent shutdown path to await pending conversation syncs, ensuring no in-flight writes are dropped.
  • Implemented a no-op wait_for_pending_syncs() in the base conversation class, with an override in StreamConversation for actual draining.

Test reliability improvements:

Robustness and documentation:

  • Improved error handling for Stream API exceptions during sync.
  • Enhanced docstrings and comments for clarity on asynchronous behavior and usage. [1] [2]

Bug fixes and pipeline improvements:

  • Prevented empty final LLM responses from being persisted, avoiding conversation history corruption and downstream provider errors.
  • Ensured TTS pipeline always signals turn boundaries, preventing hangs in streaming scenarios.

Documentation update:

  • Expanded inworld/README.md to better describe plugin capabilities.

dangusev added 30 commits May 4, 2026 10:53
Stream is a sort of queue with __aiter__ which can be cleared or closed.
Clearing the Stream keeps iterators running but drops the queued data.
Closing it signals the running iterators to stop.
Also:
- openrouter llm no longer inherits from openai.LLM
dangusev and others added 24 commits May 4, 2026 10:56
- replace assert with ValueError in collect_simple_response
- add todos to fix some undefined behavior later
send_nowait() was infinitely accumulating carryover buffer because of incorrect handling of 2d numpy arrays
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.

2 participants