feat: add StepFun Realtime plugin - #7352
yaosongding wants to merge 7 commits into
Conversation
…ion, and PII logging
… registration and settle correlated futures on error
…ng, and dangling anchors
…alization, and context correlation
…ize turn-scoped tools
There was a problem hiding this comment.
Devin Review found 1 new potential issue.
5 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
There was a problem hiding this comment.
🟡 Pending replies survive interruption
Calling interrupt() before response.created leaves the queued response undiscarded. StepFun can ignore the early cancel, so the interrupted reply later becomes live.
(Refers to this code)
Learn more
A pending generation is a response.create whose response.created acknowledgement has not arrived. The base interrupt sends response.cancel whenever a response-created future exists, but it does not cancel that future or add its event ID to _discarded_event_ids. StepFun can reject that cancel because no response exists yet. The removed state was the only path that remembered this race and discarded the eventual response.
Example: generate_reply() queues event A, then session.interrupt() runs before StepFun acknowledges A. StepFun returns “no ongoing response to cancel” and later sends response.created for A. The session now resolves A as a live generation, although the caller interrupted it.
Recommended fix: Preserve cancellation state for pending creates, or explicitly add the appropriate pending event ID to _discarded_event_ids when interrupt() targets an unacknowledged generation. Keep active-generation cancellation from marking unrelated queued replies.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Human speaking. I'm also reviewing these comments/updates simultaneously, I think I need more time. |
Summary
Adds the StepFun (阶跃星辰) Realtime Speech-to-Speech plugin (
livekit-plugins-stepfun) supporting StepAudio full-duplex speech models.Key Features & Protocol Adaptations
stepaudio-3-realtime-preview(duplex reasoning model),stepaudio-2.5-realtime(production low-latency S2S), andstep-1o-audio.api.stepfun.ai) and domestic (api.stepfun.com) endpoints.stepfun.tools.WebSearchandstepfun.tools.Retrieval(ProviderToolsubclasses) integrated withsession.update.{"type": "function", "function": {...}}).update_toolsto inspect nested function names (t["function"]["name"]), preserving local tools inself._toolsacross updates and reconnects.function_callitems insend_eventto prevent 400 Bad Request (item.type must be message or function_call_output).conversation.item.createdto pending client futures, eliminatingupdate_chat_ctxdelays._wrap_session_updatepreserves field omissions (e.g.update_instructionsnever erases configured tools).echo_gate_thresholdto suppress laptop speaker acoustic bleed during active speech while allowing intentional user interruptions.extra={"lk.pii.*"}attributes to adhere to LiveKit log sanitization guidelines.Installation
Validation
uv run pytest tests/test_plugin_stepfun_realtime.py)uv run ruff check livekit-plugins/livekit-plugins-stepfun tests/test_plugin_stepfun_realtime.py)uv run mypy -p livekit.plugins.stepfun, 7 source files checked)WebSearch, and local@function_toolexecution validated on local WebRTC meet session.