anomalyco / anomalyco/opencode

Client busy-loops (~85% CPU, zero syscalls) on long Fireworks reasoning streams — probabilistic, reproducible on 1.17.6 and 1.18.31

Open
#49,880 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

opencode run busy-loops (sustained ~85% CPU, zero syscalls, no output, no error) when a Fireworks reasoning model emits a long reasoning stream. The process never completes and never fails — it spins in userspace until killed.

Affected versions: 1.17.6 and 1.18.31 (latest at time of writing). Linux x64, Bun runtime, llm.runtime=ai-sdk.

Repro

timeout 90 opencode run --agent instruct \
  --model fireworks-ai/accounts/fireworks/models/glm-5p3-flash < prompt.txt

With a complex ~33KB prompt (a demanding extraction-style task), the process hangs until the timeout, printing only the agent banner. The identical prompt against the same model via plain HTTP (curl/httpx streaming) completes in ~20s, every time.

Characterization

  • Mechanism: strace -f -p <pid> for 20s during the hang shows zero syscalls; the process sits at ~85% CPU. Single-threaded userspace spin. The log shows stream ... agent=instruct and then nothing — no error, no retry, no parts written.
  • Probabilistic per run, scaling with reasoning volume:
    • Complex 33KB prompt: ~10/10 hangs (model emits ~9.3K reasoning deltas via API capture).
    • Same content with a "reason briefly" instruction in the prompt: 0/4 hangs.
    • Smaller slice (~7.4K reasoning deltas): ~50% hangs.
    • Synthetic large prompt with shallow reasoning (~600 deltas): never hangs, at any input size.
  • Models: Fireworks reasoning models tested (glm-5p3-flash, glm-5p3, kimi-k3, minimax-m3; deepseek-v4p1-flash intermittently — its reasoning length varies per prompt, matching its intermittent hang rate). Anthropic models not affected (no per-delta reasoning_content events).
  • Not the provider: ~100 direct API calls with identical prompts — including system+user messages, temperature 0, and 6-wide concurrency — all complete normally. SSE stream capture shows structurally normal events, finish_reason: stop, for both hanging and clean prompts.
  • Not local config: reproduced with the project's plugin directory emptied; provider.<id>.models.<m>.reasoning: false and reasoning-briefing system prompts do not prevent it.

Best guess from the outside: something in the stream/reasoning-delta accumulation degrades (superlinearly?) with event count and, past a threshold, never terminates — the hang probability tracks reasoning delta count cleanly across all experiments.

Repro prompt available on request.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce with the provided timeout 90 opencode run command against the Fireworks model and a complex prompt, then observe the process with strace to confirm the zero-syscall spin. Trace the TypeScript ai-sdk Fireworks streaming and reasoning-delta handling used by opencode run; compare it with a clean short-reasoning run. Done means long reasoning streams complete normally with output and without sustained CPU spinning.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, typescript
Domain
ai, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.