r/opencode • • 7d ago

I made a Claude plugin that orchestrates my Opencode LLM

Post image

If this is not acceptable for r/opencode I apologize. Opencode is about 50% of the project, the other half is Claude. It's a hybrid solution I'm working on and wanted to share around. Thanks.

https://github.com/a-schaefers/claudes-workbench

3 Upvotes

3 comments sorted by

1

u/mwilson_9309 5d ago

How do you split the work between Claude and OpenCode, and what does the handoff look like?

1

u/adam-schaefers 5d ago

Sizing. Each step is one concern, no bigger than what that model has been measured to finish in its context window. Workbench tracks this per model; on a 32K window it's about 2–3 files and 150 lines. Small requests in the same area are bundled into one task, because each handoff has a fixed cost of about 50K Claude tokens.

The handoff:

  1. Spec and start. Claude writes a short spec: the goal, the files to read and change, any exact names other code relies on, and an acceptance command. Then it runs wb start <task> --spec … --test '<command>'. A router picks the model from its record on past tasks of that size, and wb start returns at once.
  2. The runner drives the agent. A detached process makes a fresh git worktree and a branch. It checks the acceptance command once on the untouched code, then runs OpenCode round by round. Guards stop the agent if it loops, goes silent or stalls. When the agent's context fills up, the task passes to a fresh session along with the diff so far.
  3. Cheap iterations stay local. When a round ends, the runner runs the tests. Failures go back to the agent automatically for a few rounds. Once they pass, the agent checks its own diff once more. Claude isn't involved yet.
  4. Claude is woken only when needed: to review, to answer the agent's question (an ask_reviewer tool that blocks until Claude answers), or when the task is stuck or failed. Claude doesn't poll. The Claude Code plugin delivers the notice.
  5. Review. Claude reads the whole diff against the spec and holds it to the bar it would set for its own code. For significant changes it also breaks the code on purpose to confirm the tests catch it. Then it does one of three things:- wb feedback: send concrete fixes for another round, at most three review rounds;- wb next: commit this step and give the same agent the next one;- fix a small nit itself.
  6. Accept. wb accept commits under the user's own git identity, with no AI co-author line. The commit carries trailers recording which task and session produced it. The result (accepted or discarded, rounds, cost) is logged, and the router and per-model sizing learn from it.

1

u/i_hossain_22329 4d ago

How much agent-side token usage does a typical task add on top of that roughly 50K Claude-token handoff cost?