You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feature: OpenCode support — detection, settings, parsed events, token and cost accounting #941
Second agent on the agent integration contract, and the first non-Claude one. OpenCode is
open source, so it is the integration anyone outside the team can reproduce.
Proposed Solution
Detect an installed OpenCode and locate its settings
Patch it to use localhost:47600 and the Cortex CA; ask before editing, support revert
Traffic parsed into typed events, not merely proxied
Token counts and cost correct for its wire format; if it is not Anthropic-shaped, either
parse it properly or emit a clearly-labelled partial event
Session and cost metrics aggregate alongside Claude Code sessions, with field names
agreed with per-session token and cost aggregation
A tool inventory for OpenCode, or state explicitly that tool pruning is unsupported for
it — without one, pruning silently saves nothing
Required artifact: a doc for OpenCode
This issue does not close on code alone. The doc is a deliverable like the code: it ships
in the same PR, or in a linked PR merged before this issue closes. A PR description or a
comment here does not count.
It is docs/agents/opencode.md in this repo, linked from the root README's Any agent works line
and from the index in docs/agents/README.md (#939). It covers:
Enable and revert — the agentop configure commands for OpenCode, which file each one
writes, and how to undo it by hand
CA trust — what OpenCode needs to trust the Cortex CA, and the symptom when it does not
What Cortex shows for it — which events are typed, which token and cost fields are
filled, and what is partial or unsupported (e.g. tool pruning)
Verified depth — the OpenCode versions and platforms actually tested, and what was not
Known issues specific to OpenCode
cmd/agentop/README.md can carry the command reference too; it does not replace this page.
Additional Context
Part of the Cortex v0.9.0 release. Depends on the agent integration contract.
Noting #1239 (OpenAI Responses API support in inference-parser) as a related issue — surfaced while scoping #942 (Codex), but relevant here too since it's about a wire-format gap in the shared parser, not an agent-specific one.
Closing: every criterion is met on main (d1ca6102). #1243 said "part of #941", so this never auto-closed.
Detect, patch, ask, revert:Feat: Support OpenCode as a coding agent #1243. agentop configure opencode enable|disable|status asks before editing (--yes skips the prompt), and disable removes only Cortex's values; the prior state is kept in ~/.cortex/opencode-state.json.
Tokens and cost:Fix: Parse and price OpenCode Zen's endpoints #1247. Zen's free models are priced at zero and Claude models at Anthropic list rates. Anything else stays unpriced until a pricing: entry is added.
Doc:docs/agents/opencode.md covers enable/revert, CA trust, what Cortex shows, verified depth and known issues. It is linked from the README's Any agent works line.
Activity
esnible commentedon Sep 11, 2026
See https://opencode.ai/ for OpenCode install instructions.
Those instructions mention ~/.config/opencode/opencode.json perhaps it is ~/.config/opencode/opencode.jsonc ?
The content in that file became
{ "$schema": "https://opencode.ai/config.json", "provider": { "litellm": { "npm": "@ai-sdk/openai-compatible", "name": "LiteLLM", "options": { "baseURL": "https://ete-litellm.ai-models.vpc-int.res.ibm.com" }, "models": { "gpt-5.6-terra": { "name": "GPT-5.6 Terra" }, "claude-sonnet-5": { "name": "Claude Sonnet 5" }, "deepseek-chat": { "name": "DeepSeek Chat" } } } } }I then started OpenCode with
abctl exec -- opencodeI was now able to
/connectwithlitellmand supply my LiteLLM API key interactively.I then was able to interact and had no trouble observing token counts in abctl.
Alan-Cha commentedon Oct 2, 2026
Noting #1239 (OpenAI Responses API support in
inference-parser) as a related issue — surfaced while scoping #942 (Codex), but relevant here too since it's about a wire-format gap in the shared parser, not an agent-specific one.feat: Recognise OpenCode's User-Agent and read its session header
feat: Add peerproc.Environ, the environment a process started with
fix: Report a withheld or unreadable environment as ErrNotFound
4 remaining items
fix: Leave a value disable did not set alone, whatever the record says
fix: Recognise Cortex's proxy by listener, not spelling, in configure…
docs: Add the OpenCode agent page
fix: Say that configure opencode stops OpenCode's service, and ask first
fix: Group OpenCode by X-Session-Id, as the laptop installer already …
fix: Restart OpenCode's service once after configure opencode changes it
docs: Say how OpenCode is grouped and how configure opencode restarts it
docs: Record the live run of configure opencode's restart
fix: Read X-Session-Id by default on laptop installs only
fix: Say only what configure opencode knows; keep the user's own prox…
fix: Name the restart a failed restart needs; say why X-Session-Id is…
fix: Parse OpenCode Zen's Anthropic-dialect endpoints
fix: Price OpenCode Zen's free models at zero
huang195 commentedon Oct 5, 2026
Closing: every criterion is met on
main(d1ca6102). #1243 said "part of #941", so this never auto-closed.agentop configure opencode enable|disable|statusasks before editing (--yesskips the prompt), and disable removes only Cortex's values; the prior state is kept in~/.cortex/opencode-state.json./v1/messagesand/zen/go(Fix: Parse and price OpenCode Zen's endpoints #1247), and any path prefix (Fix: Parse known inference dialects under any path prefix #1248).pricing:entry is added.opencodeagent row, grouped byX-Session-Id(Feat: Support OpenCode as a coding agent #1243). Header-less traffic is attributed by process (Feat: File header-less traffic by the process that sent it #1230).docs/agents/opencode.mdcovers enable/revert, CA trust, what Cortex shows, verified depth and known issues. It is linked from the README's Any agent works line.Not covered here:
docs/agents/README.mdis part of feature: agent integration contract — reusable detection, settings patching, and revert #939, which creates that index./zen/v1/responses(GPT and Grok models) is recorded but not parsed yet; that is feature: OpenAI Responses API support in Cortex's inference-parser #1239.