Title: Qwen-Omni Realtime API - Invalid session.finish event, session failure on ws.close(), and VAD token consumption inquiry · Issue #140 · dashscope/dashscope-sdk-python · GitHub
Open Graph Title: Qwen-Omni Realtime API - Invalid session.finish event, session failure on ws.close(), and VAD token consumption inquiry · Issue #140 · dashscope/dashscope-sdk-python
X Title: Qwen-Omni Realtime API - Invalid session.finish event, session failure on ws.close(), and VAD token consumption inquiry · Issue #140 · dashscope/dashscope-sdk-python
Description: Context / Background I am using the Qwen3.5-Omni-Flash-Realtime model over a WebSocket connection. I reviewed the sample implementation provided in your repository at: https://github.com/aliyun/alibabacloud-bailian-speech-demo/blob/maste...
Open Graph Description: Context / Background I am using the Qwen3.5-Omni-Flash-Realtime model over a WebSocket connection. I reviewed the sample implementation provided in your repository at: https://github.com/aliyun/ali...
X Description: Context / Background I am using the Qwen3.5-Omni-Flash-Realtime model over a WebSocket connection. I reviewed the sample implementation provided in your repository at: https://github.com/aliyun/ali...
Opengraph URL: https://github.com/dashscope/dashscope-sdk-python/issues/140
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Qwen-Omni Realtime API - Invalid session.finish event, session failure on ws.close(), and VAD token consumption inquiry","articleBody":"### Context / Background\n\nI am using the **Qwen3.5-Omni-Flash-Realtime** model over a WebSocket connection. I reviewed the sample implementation provided in your repository at:\n`https://github.com/aliyun/alibabacloud-bailian-speech-demo/blob/master/samples/conversation/omni/python/run_server_vad.py`\n\n### Problem 1: Invalid `session.finish` event \u0026 Missing Graceful Shutdown\n\nWhen attempting to gracefully shut down the WebSocket connection, I tried sending a `session.finish` event type, same as the sdk of Realtime API specifications:\n\n```json\n{\n \"event_id\": \"...\",\n \"type\": \"session.finish\"\n}\n\n```\n\nHowever, the server returns an error stating that this is an **invalid event type**.\n\nLooking closely at your sample code (`run_server_vad.py`), it only calls `conversation.close()`, which internally just executes `ws.close()`. This abruptly terminates the WebSocket connection without a proper higher-level elegant handshake or session termination event.\n\n### Problem 2: Dashboard showing \"Failed\" sessions \u0026 Token usage tracking\n\nBecause the connection is abruptly killed via `ws.close()`, every single one of my Realtime API sessions is marked as **\"Failed\"** in my Qwen Cloud Console / DashScope Dashboard. This makes it extremely difficult to track my exact token usage, session histories, and accurate analytics.\n\n\u003cimg width=\"851\" height=\"527\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/c8c27fd5-5043-4b29-ac24-953268221dbd\" /\u003e\n\n\u003cimg width=\"452\" height=\"685\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/78feb200-61c3-4826-be89-1304775da247\" /\u003e\n\n* Is the rejection of `session.finish` expected behavior, or is there another protocol-compliant event to gracefully close a session?\n* Is there a bug on the server side that records abrupt `ws.close()` actions as session failures?\n\n---\n\n### Question 3: VAD Token Consumption\n\nAdditionally, I have a question regarding the Voice Activity Detection (VAD) mode.\nWhen VAD is enabled, **does the server consume any tokens during the idle state** (i.e., when the client is streaming background silence/noise before the actual speech or user message is triggered/recognized)?\n\n### Environment\n\n* Model: Qwen3.5-Omni-Flash-Realtime\n\nAny clarification or guidance on how to properly perform a graceful shutdown and understand VAD token mechanics would be greatly appreciated. Thank you!\n","author":{"url":"https://github.com/ptaejoon","@type":"Person","name":"ptaejoon"},"datePublished":"2026-06-15T10:21:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/140/dashscope-sdk-python/issues/140"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ba4786df-0eb9-cb91-db89-8806e3ec9f1e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8BDA:C1A48:276975:357A26:6A6290CC |
| html-safe-nonce | ca2b8e0438c64466afb61a6460b7eabaeb50d70ff9bcb99cea8225d93933f4ac |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkRBOkMxQTQ4OjI3Njk3NTozNTdBMjY6NkE2MjkwQ0MiLCJ2aXNpdG9yX2lkIjoiODM3ODYwOTE5MzM2NTcwNDkwOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5990aff60569accf238420a88d7fe2443c0334bfa5fcabbba9fe5262e352550a |
| hovercard-subject-tag | issue:4664181500 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/dashscope/dashscope-sdk-python/140/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ec1ad0bf037f1e98cd9819d7e2c3df44660b2d08d188a3608e0fa9846d1f4ea3/dashscope/dashscope-sdk-python/issues/140 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ec1ad0bf037f1e98cd9819d7e2c3df44660b2d08d188a3608e0fa9846d1f4ea3/dashscope/dashscope-sdk-python/issues/140 |
| og:image:alt | Context / Background I am using the Qwen3.5-Omni-Flash-Realtime model over a WebSocket connection. I reviewed the sample implementation provided in your repository at: https://github.com/aliyun/ali... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ptaejoon |
| hostname | github.com |
| expected-hostname | github.com |
| None | ac2209d8cb6970a1bd08cb0a3f821d7166ac544c2ca1c87819c335bb84310ecd |
| turbo-cache-control | no-preview |
| go-import | github.com/dashscope/dashscope-sdk-python git https://github.com/dashscope/dashscope-sdk-python.git |
| octolytics-dimension-user_id | 127009744 |
| octolytics-dimension-user_login | dashscope |
| octolytics-dimension-repository_id | 944303085 |
| octolytics-dimension-repository_nwo | dashscope/dashscope-sdk-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 944303085 |
| octolytics-dimension-repository_network_root_nwo | dashscope/dashscope-sdk-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2fca8cd598678aaa64706088ad13b4e19177e108 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width