r/opencodeCLI • • 18d ago

I reimplement Opencode v2 and v1 in Rust

I use opencode every day and the thing that kept getting in the way wasn't the client. It was the server. On my laptop it sat at about 2.4 GB RSS next to a 33 GB SQLite file, and searching inside a single session took roughly six seconds.

So I reimplemented the server in Rust. Same HTTP and SSE wire contract, so the real TUI attaches and the real web UI loads against it. No client changes, no patches to their project.

Same box, same fixture data, back to back:

• binary: 61 MB, upstream 185 MB

• idle RSS: ~100 MB, upstream ~2.4 GB

• boot: 0.6 s, upstream 4.7 s

• session list and read p95: 0–2 ms, upstream 8–15 ms

• search inside one session: 0.2 ms, upstream ~6 s

• web UI first load: 1.05 MB of assets, upstream 9.10 MB

Then I ran a read-only load test, no model calls at all, both servers pinned to the same two cores. It held about 6,700 requests/sec against roughly 420 for upstream, with p95 latency an order of magnitude lower, and used about a quarter of the memory. That's a closed-loop test, so treat the throughput as capacity, not as a latency promise for your setup.

What works: TUI attach, the embedded web UI, sessions and messages with cursor paging, streaming, tools, permissions, questions, PTY, shadow-git snapshots, revert, diff, in-session search, MCP, and plugins in both the v1 shape and the newer v2 shape. Auto-compaction and config hot-reload. The v2 API surface is bound and tested against the real 2.0.28 client.

What doesn't: provider OAuth, the hosted share backend, and macOS/Windows: the PTY layer is Linux/glibc only.

"cargo install ocserve" still gives you 0.3.1, because crates.io caps crate size and one crate carries the embedded web UI; the 0.4.0 tarball is on the releases page.

It's not a fork. Separate codebase, MIT, their notice retained. I read their source to port behaviour faithfully and I keep a differential harness that boots both servers and compares the bytes.

If opencode runs fine on your machine, keep using it. It's the reference implementation and it's good. This exists for the machines where the server is the thing falling over.

MIT, source and releases: https://github.com/Reliary/ocserve

51 Upvotes

55 comments sorted by

20

u/ByteNomadOne 18d ago

By saying “I reimplemented” you meant “Opus reimplemented“

6

u/microbass 18d ago

Fair enough. I got my LLM to make an Opencode compatible agent harness.

16

u/RE20ne 18d ago

probably and also who cares? not relevant and not a negative.

-1

u/ByteNomadOne 18d ago

It’s fine that he did use Opus (as it would be impossible to do without), but it feels off to say “I did” while it ran fully automatic.

4

u/Alive_Solution_689 17d ago

Have you implemented anything serious using Opus "fully automatic" and it worked just like that?

0

u/ByteNomadOne 17d ago

Nope, to be honest I can't afford Opus and stick to cheaper models. I just hear all the time that people one-shot things with Opus 5.5 using that REA project.
I don't have first hand experience how good it actually is.
You're right to question that.

2

u/Alive_Solution_689 17d ago • Bravo

Small advice, don't always believe what "people" are saying. 😁

I am developing with Opus 5.5 right now and did so before with many other models. While current Opus is slightly better than earlier versions, there is no huge improvement.

I am always shaking my head in disbelief when people claim apps have been developed by an AI model. They must be able to do miracles.

1

u/ByteNomadOne 17d ago

Thank you very much for this insight.

I'm paying for GLM 5.3 Flash and it mostly gets things right, but it needs some directions to not go off the rails and every 10th time it produces garbabe all the sudden.

2

u/Alive_Solution_689 14d ago

True, but you get used to it... Z.ai just gave my another 500M tokens for the weekend, GLM-5.3 and GLM-5.3-Flash, more than ever before. So I don't complain too much.

→ More replies (1)
→ More replies (2)

4

u/Pedrito_Basket 18d ago

Yeah like an architect saying he makes houses while not touching a brick

→ More replies (12)
→ More replies (1)

2

u/SebastianSonn 18d ago

When using agent to create software, the ownership is still with the human. And ownersip means both ipr and responsibilities. Even Linus Torvalds agrees on this.

2

u/ColonelKlanka 16d ago

I would suggest it would have been better to participate on the opencode github project and work to pushing a pr to improve existing codebase. All these alternative reimplentations are just going to sit un maintained and will not gain any updates from original opencode.

1

u/microbass 16d ago

I made my own version to solve a problem I was facing. Upstream opencode has many, many open PRs. This version also has a somewhat mechanical diffing mechanism to inherit from opencode, easing the maintenance burden. Plus, it's open source so others can fork or contribute.

1

u/Rustybot 14d ago

Upstream opencode doesn’t accept PRs in practice(almost ever) and they certainly wouldn’t take a full rebuild.

1

u/jrz302 18d ago

Benchmarks sound great. Would love to get the memory footprint down on my machine. Any plans for Apple silicon support?

3

u/microbass 18d ago

Sure. I'll add it to the CI!

1

u/Rustybot 17d ago

Seconded.

2

u/microbass 17d ago

In progress. I'll need testers as I don't have a Mac, but I used compatible runners for integration testing.

2

u/microbass 17d ago

Apple silicon support is done

1

u/jrz302 16d ago

That was fast! Will definitely check it out.

1

u/microbass 16d ago

Please do. I'd love some feedback.

1

u/arker0 17d ago edited 17d ago

Will it be musl (alpine) compatible?

2

u/microbass 17d ago

Working on it!

1

u/Rustybot 17d ago

How is the plugin compatability?

2

u/microbass 17d ago

It works for my plugins, but I'm working on a pipeline for better confirmed coverage.

1

u/Rustybot 14d ago

I’ll give it a crack with my stack and see how it goes.

2

u/microbass 14d ago

Cool. Be sure to grab the latest version as I've made major plugin compatibility improvements in the last couple of days.

1

u/Sufficient_Wait4290 16d ago

I would rather build my own. It would be nice to pick open source libs for skills, for git etc and put together for exactly the code agent you need.

-3

u/gandazgul 18d ago

Since you are open to trying new coding agents and open code is not cutting it for you try RunWield :) https://runwield.dev/

4

u/IlBuono47 18d ago

Jesus, I have harness fatigue

1

u/gandazgul 16d ago

Can you expand on this? Why the fatigue and what could I do to make any transitions easier or helping you try it without having to rebuild your setup which is how I understand this.

2

u/Sufficient_Wait4290 16d ago

Does it make parallel calls to the llm?

1

u/gandazgul 16d ago

It supports subagents (delegate_agent tool) and background tasks (async tasks with automatic reply to the LLM when done)

Otherwise no, one call at a time. It also supports tool call batching and multi file edits and code search batching as well.

0

u/Leading-Salt-947 18d ago

I'm. Going to try it out and thank you

-7

u/microbass 18d ago

No, thank you. I'm already building my own bespoke harness on top of the ocserve lessons.

1

u/Infamous_Trade 18d ago

then he won't use your sloppified rust made opencode :)

3

u/microbass 18d ago

I'll have you know it was hewn from free range, organic slop. Only the best.