anomalyco / anomalyco/opencode
Bulk fork-and-replay duplicates sessions with byte-identical token costs
@nexxeln is already working on this.
Since Sep 9, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 384
Description
Summary
Forking a session appears to trigger a bulk fork-and-replay tool event that creates MULTIPLE sessions in the same second, each replaying the entire parent conversation at full cost.
Evidence (from local opencode.sqlite, May 12 2026)
Six sessions created within 4 seconds, all titled LA Confidential bookpacking project outline (fork #1), all with byte-identical cost/token totals:
| Session | Created (local) | Cost | Tokens |
|---|---|---|---|
| ses_1e492ef24ffe... | 09:03:13 | 3.7198358828 | 4,163,128 |
| ses_1e492eba7ffe... | 09:03:14 | 3.7198358828 | 4,163,128 |
| ses_1e492e7b5ffe... | 09:03:15 | 3.7198358828 | 4,163,128 |
| ses_1e492e6cbffe... | 09:03:15 | 3.7198358828 | 4,163,128 |
| ses_1e492e53dffe... | 09:03:15 | 3.7198358828 | 4,163,128 |
| ses_1e492dca8ffe... | 09:03:17 | 3.8881539728 | 4,270,855 |
Five sessions have byte-identical cost (3.7198358828) and token count (4,163,128) — impossible for independent runs. This looks like a single fork operation that replayed the parent conversation 5-6 times, each billed at full price. Combined cost: ~$22.49 (33% of the user's total spend across 256 sessions).
Root-cause hypothesis
A single fork action (or a UI double-click / keyboard repeat) fans out into multiple replay sessions. The parent session (May 7, 4,168,367 tokens, $3.79) was replayed at the same scale, so each clone costs as much as the original.
Impact
- $22.49 wasted on 6 duplicate sessions
- Duplicate sessions pollute session lists and make it impossible to tell which fork is the 'real' continuation
- Recurring: a May 7 fork of the same session shows the same pattern
Suggested fix
- Debounce/dedupe fork creation (e.g., ignore fork requests within ~2s of the previous one)
- Or: make fork a lightweight operation (copy session metadata + message references) instead of replaying the full conversation
- Or: at minimum, warn when a fork would replay >1M tokens at full cost
Environment
- opencode (local install), macOS
- DB evidence:
~/.local/share/opencode/opencode.db, tablesession, columncost/token totals
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.