Skip to content

feature: OpenCode support — detection, settings, parsed events, token and cost accounting #941

Closed

Description

@huang195

Feature Description

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.

Activity

  1. added this to the Release V0.9.0 milestone on Sep 10, 2026
  2. esnible commented on Sep 11, 2026

    @esnible
    Member

    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 -- opencode
    I was now able to /connect with litellm and supply my LiteLLM API key interactively.

    I then was able to interact and had no trouble observing token counts in abctl.

  3. self-assigned this
    on Oct 1, 2026
  4. Alan-Cha commented on Oct 2, 2026

    @Alan-Cha
    Member

    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.

  5. 4 remaining items

  6. huang195 commented on Oct 5, 2026

    @huang195
    MemberAuthor

    Closing: every criterion is met on main (d1ca6102). #1243 said "part of #941", so this never auto-closed.

    Not covered here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions