omi icon indicating copy to clipboard operation
omi copied to clipboard

omi-twitter-app: a trigger-only segment stores None and crashes the next recording segment

Open emiwltz opened this issue 2 months ago • 1 comments

Symptom

In plugins/omi-twitter-app/main_simple.py, send a segment containing only Tweet now, then a second segment containing A useful update. The first call to process_segments returns collecting_1, but saves accumulated_text=None. The second call raises:

TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'

TweetDetector.extract_tweet_content("Tweet now") deliberately returns None for an empty body. The recording transition stores that nullable result without normalization (line 711); session.get("accumulated_text", "") (line 720) does not substitute the default for a present key whose value is None. The next += therefore crashes rather than collecting the spoken content. An existing recording session with a null accumulator has the same problem.

Source read on 2026-09-17: main_simple.py blob dfbae89d7097c009d61e0dc3577b7cabc0ae66a8; simple_storage.py blob 14790336dc2bc229a14f4b90a0623eb4cd621486.

This is distinct from #14351 / #14353: the reproduction has no leading whitespace and concerns the recording state transition, not offset calculation in the detector.

Reproduction without services

Save this as reproduce_empty_trigger.py, then run python3 reproduce_empty_trigger.py plugins/omi-twitter-app from a checkout. It selects the actual production definitions through AST to avoid import-time OAuth, disk loading, FastAPI setup and external SDK initialization. It makes no network calls and never reaches the posting step.

import ast
import asyncio
import re
import sys
from datetime import datetime
from pathlib import Path
from typing import Any, Dict, List, Optional

source = Path(sys.argv[1])
sessions = {}


def load(filename, name):
    tree = ast.parse((source / filename).read_text(encoding="utf-8"))
    node = next(n for n in tree.body if getattr(n, "name", None) == name)
    exec(compile(ast.Module(body=[node], type_ignores=[]), filename, "exec"), globals())


load("simple_storage.py", "SimpleSessionStorage")
load("tweet_detector.py", "TweetDetector")
load("main_simple.py", "process_segments")
tweet_detector = TweetDetector()


async def main():
    session = SimpleSessionStorage.get_or_create_session("fixture", "fixture-user")
    user = {"access_token": "fixture-only"}
    print("FIRST:", await process_segments(session, [{"text": "Tweet now"}], user))
    print("ACCUMULATOR:", repr(session["accumulated_text"]))
    print("SECOND:", await process_segments(session, [{"text": "A useful update"}], user))


asyncio.run(main())

Candidate correction

Normalize the accumulator when entering recording and when resuming a previously null session:

--- a/plugins/omi-twitter-app/main_simple.py
+++ b/plugins/omi-twitter-app/main_simple.py
@@ -708,7 +708,7 @@
         SimpleSessionStorage.update_session(
             session_id,
             tweet_mode="recording",
-            accumulated_text=tweet_content,
+            accumulated_text=tweet_content or "",
             segments_count=1
         )
         
@@ -717,7 +717,7 @@
     
     # If in recording mode, collect more segments
     elif session["tweet_mode"] == "recording":
-        accumulated = session.get("accumulated_text", "")
+        accumulated = session.get("accumulated_text") or ""
         segments_count = session.get("segments_count", 0)
         
         # Add this segment

Verification and limits

I executed the reproducer locally under Python 3.13.5 against extracted, unchanged production definitions from the files above: before the patch, exit 1 with the TypeError; after the patch, exit 0 and SECOND: collecting_2.

A separate local component suite passes all 10 tests after the patch, covering the five bare trigger phrases, the second/third recording steps, null and missing legacy accumulators, normal content, passive listening, a rejected post, empty extraction and reset/no duplicate post. The LLM extraction and Twitter posting calls in that suite are AsyncMock boundaries; detector matching, session storage methods and the recording function execute production logic. Regression cases fail on the unpatched definitions.

This is not a live X/Omi test, full-repository test run or make preflight result. A repository-integrated PR would still need the normal manifest registration and contribution checks.

Bounty proposal

Under the Contribution Guide's option to suggest a bounty, would you consider US$100 for the reviewed fix and hermetic regression coverage? This amount is a proposal, not an approved or claimed reward. @josancamon19

AI-assisted investigation performed on behalf of this account's holder; no production accounts or services were accessed.

emiwltz avatar Sep 17 '26 16:09 emiwltz

I have submitted a clean, fully verified pull request to fix this issue: #14695.

shuoYun114 avatar Sep 19 '26 04:09 shuoYun114