5c2a215fca
oh-my-opencode run exits within ~1.5s of starting because pollForCompletion checks completion too early. When the agent outputs its first text but hasn't created todos yet, the empty state (0 todos, 0 children) passes all checks. Root cause timeline: 1. promptAsync fires 2. Agent outputs text (e.g. 'ULTRAWORK MODE ENABLED!') -> hasReceivedMeaningfulWork = true 3. Agent pauses before todowrite -> session briefly goes idle 4. pollForCompletion: idle=true, tool=null, work=true -> checkCompletionConditions 5. 0 todos = 'all complete', 0 children = 'all idle' -> true 6. 3 consecutive checks (1.5s) -> premature exit 0 Fix: Add a minimum stabilization period (10s) after the first meaningful work before checking completion conditions. This gives agents time to create todos and spawn child sessions. The period is configurable via PollOptions for tests. Note: todo 0 remaining 'all complete' is correct behavior — some agents don't use todos. The stabilization period is the proper fix, not changing completion semantics.