oc-run

A command that delegates a task to the OpenCode worker through OpenRouter, records progress, and stores the session so it can be monitored or resumed.

In plain words
What is it for?
Use it for OpenCode tasks, especially repository changes run in an isolated Git worktree. It requires the OpenCode tools and an OpenRouter API key.
Why use it?
It provides a way to hand off work while keeping progress visible and the session recoverable.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/rbinar/cli-dispatch/oc-run
Clone the repo
git clone --depth 1 https://github.com/rbinar/cli-dispatch
Per session 12 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 984 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00012 $0.00984
Opus 5 $0.00006 $0.00492
Sonnet 5 $0.00002 $0.00197
Haiku 4.5 $0.00001 $0.00098

Measured yesterday against content hash ecb2f7336b97, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

oc-run scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/cli-dispatch/commands/oc-run.md · 74 lines

What it actually says

Delegate a task to the OpenCode worker

Task to delegate: $ARGUMENTS

The task runs via oc-stream — it pipes opencode run --format json --auto stdout through oc-stream-parse.mjs for live progress + a rolling status.json, writing the same session directory layout the other backends use → live, observable, resumable. Monitor progress in a cost-conscious way: read only the small status.json, never the raw transcript. The session id is the opencode session id (relocated into place once known, printed on stderr).

Prerequisite: oc-agent / oc-stream installed (/cli-dispatch:setup, OpenCode backend) and OPENROUTER_API_KEY set in the config — OpenRouter has no OAuth/login flow, the key is the only auth path.

If it's a real repo task (file changes needed) — isolate in a git worktree:

  1. Use the bundled helper, which creates the worktree off origin/main, symlinks every node_modules dir of the source checkout (root + workspace packages, resolved from the repo top even when <repo-path> is a subdirectory), runs oc-stream in it, and prints the cleanup command:
    "${CLAUDE_PLUGIN_ROOT}/scripts/oc-worktree-run.sh" <repo-path> oc-run-<branch-name> <brief-file>
    
    Or run it by hand:
    WORKTREE=$(mktemp -d)
    git worktree add "$WORKTREE" -b oc-run-<branch-name> origin/main
    oc-agent --cwd "$WORKTREE" --max-runtime 600 "$ARGUMENTS"
    
  2. Monitor (cost-conscious): capture the session id from stderr, then check progress via /cli-dispatch:watch <session-id> (state: running→done). Do NOT tight-loop tail.
  3. When done, review the diff (git -C "$WORKTREE" diff), verify independently (build/test).
  4. If all good, you handle git/commit/push/PR/merge; then clean up the worktree.

If it's pure generation (code/text, no files) — as a background task:

oc-agent -q "$ARGUMENTS"   # stdout = final answer only; progress in status.json/progress.log

No sandbox — read this before trusting the output unattended: --auto (always passed by oc-stream) auto-approves every permission prompt — a functional requirement for headless use, not a safety opt-in. OpenCode has no OS-level or tool-level write-deny at all, unlike Codex's real kernel-enforced --read-only. There is no --sandbox flag here to reach for. Isolation via a git worktree + your own diff review is the ONLY safety boundary.

Model selection:

oc-agent --model google/gemma-4-31b-it:free -q "$ARGUMENTS"

Pass the bare OpenRouter slug — no openrouter/ prefix — oc-stream prepends it. A few example free-tier slugs (:free suffix): google/gemma-4-31b-it:free, meta-llama/llama-3.3-70b-instruct:free, qwen/qwen3-coder:free. The free catalog rotates often, so re-verify before relying on any of these. List live models OpenCode recognizes with:

OPENROUTER_API_KEY=<key> opencode models openrouter

Omit --model to use OpenCode's own default (or the OC_MODEL config value).

Follow-up / fix (continue the same OpenCode session):

oc-agent --resume <session-id> "<follow-up>"

This passes --session <id> --continue to opencode run. Resume semantics verified live (with a real OPENROUTER_API_KEY): --session <id> --continue resumes the named session, not just "the last one".

To see all sessions (all backends), use /cli-dispatch:sessions.

The worker = OpenCode (OpenRouter); you = reviewer/merge owner. Don't trust the output until verified.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 74 lines · 12 tokens per session scan A ecb2f7336b97

Subscribe to this mod's changes

oc-run is a command published in the GitHub repository rbinar/cli-dispatch (5 stars, last pushed 14d ago), licensed MIT. It adds 12 tokens to every session and 984 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.