Skip to content

OpenCode

tenfyzhong edited this page Oct 17, 2026 · 14 revisions

OpenCode

Agentix connects to the original OpenCode TUI using its plugin API. OpenCode 2.0.32 or newer is required; 2.0.32 is the validated baseline. Earlier 2.0 patches and 1.x are unsupported. Later native API changes require compatibility testing. Keep that terminal running while using IM; attaching does not start a resumed copy of the agent.

Availability

OpenCode support is unreleased and currently available from the feature checkout. Build/install Agentix and Taskix from that checkout and use SOURCE=local below. SOURCE=main becomes usable after this support lands on main; published release binaries do not yet include it.

Install the plugins

Install the matching Agentix and Taskix builds, OpenCode, Node.js 24+ and npm. For the current Homebrew 2.x channel, use brew install anomalyco/tap/opencode-v2 (or brew upgrade anomalyco/tap/opencode-v2 when already installed), then verify opencode --version. The legacy opencode formula/npm opencode-ai channel can remain on 1.x; the 2.x npm package is @opencode/cli. If the legacy Homebrew formula owns the opencode link, run brew unlink opencode before installing opencode-v2. Keep existing configuration/authentication files.

From the feature checkout, run:

make plugin SOURCE=local HOSTS=opencode

After the support lands on main, install from an Agentix checkout with Git available:

make plugin SOURCE=main HOSTS=opencode

Use these Make targets to configure both native entrypoints. Installing the repository package alone does not perform that setup. The plugins use native 2.x setup/cleanup objects and plain JSON Schema without Zod or an npm dependency repair.

OpenCode is an explicit selection: bare make plugin still targets Codex, Pi, OMP and Claude Code. The installer stages dependency-free package directories under .agentix-plugin inside the OpenCode configuration directory.

The configuration directory is OPENCODE_CONFIG_DIR, or $XDG_CONFIG_HOME/opencode, defaulting to ~/.config/opencode. The installer adds the Bridge package to cli.json/cli.jsonc and Taskix Manager to opencode.json/opencode.jsonc, using plugins. The Bridge package exports ./tui; Taskix uses its default server export. Existing unrelated configuration, comments and plugin references are preserved. When both JSON and JSONC exist, the installer cleans stale Agentix references in both and adds the current entry once to JSONC. Legacy Agentix tui.json and singular plugin references are removed. An update stages the package before replacing the previous installation. Restart OpenCode after installing or updating. To remove these integrations:

make remove-plugin HOSTS=opencode

Removal preserves unrelated plugins and settings. See Taskix Manager for Taskix configuration and optional routing.

Configure Agentix

Add this table to ~/.config/agentix/config.toml alongside your chat channel:

[agent.opencode]
command = "opencode"
state_dir = "~/.local/share/agentix/opencode"

The fields shown are their defaults. state_dir contains Agentix delivery receipts and queues; it is separate from OpenCode's database. If you customize it, export the same absolute path in terminals that start OpenCode:

export AGENTIX_OPENCODE_STATE_DIR=/absolute/path/to/opencode-bridge-state

For a custom [server].endpoint, also export AGENTIX_CONTROL_ENDPOINT with the matching value. For example:

export AGENTIX_CONTROL_ENDPOINT=unix:///absolute/path/to/control.sock

For loopback TCP, including Windows, use an endpoint such as tcp://127.0.0.1:32198 on both sides. Agentix supplies the configured endpoint and state directory to OpenCode sessions launched from its terminal menu, using --standalone so the new native server inherits that environment.

Start and attach

Start agentix serve. In another terminal, change to your project directory and run opencode. Run agentix doctor, then select the session with /sessions opencode in IM. Public IDs have the form opencode:<native-session-id>.

With rmux or tmux available to Agentix, /rmux opencode or /tmux opencode opens the corresponding terminal menu. Choose a pane and start OpenCode there to attach the new session. Ordinary attachment to an existing TUI does not require a multiplexer.

Supported controls

Send ordinary chat messages for prompts and streamed replies. /last, /history, /stop, /queue, /queue resume, /queue clear, /new, /status, /rename, /model, /compact, /diff and /skills use native APIs or the bridge's delivery queue. The session's help shows available controls. Steering, fork and reasoning controls are not exposed.

An IM model choice updates the native session model. The original TUI still sends its own locally selected model with its next prompt, so select the same model there if you want later terminal prompts to use it.

/new stops active work and creates a new native session in the same TUI. Agentix follows the replacement. Resuming an existing session does not inherit another session's queue. /detach leaves the terminal running.

Permissions and questions

Native permission requests appear as IM actions preserving OpenCode's choices: Allow once, Always allow, and Reject. Always allow retains OpenCode's native rule scope; it is not limited to the current IM attachment. Reject denies the requested tool and sends explicit rejection feedback, allowing the assistant to respond. Use /stop to interrupt the whole execution.

Questions appear one at a time. Multiple-choice questions allow selecting several options before Submit. An Other… path is hidden when the native event explicitly sets custom: false. Agentix maps native string and multiselect form fields, preserving option values and custom-input rules. Conditional forms, other typed fields and unsupported validation constraints require the native terminal; IM still offers rejection. Agentix submits all supported answers together; rejection cancels the native form with explicit feedback so the assistant may respond. Use /stop to interrupt the whole execution. Answering in the original TUI retires the corresponding IM controls. Old buttons cannot answer a later request.

Queue recovery

The bridge records accepted delivery IDs before submission and does not automatically resend them after a lost response or restart. An in-flight delivery recovered from disk is marked uncertain and pauses the queue. Inspect /history and /queue, then use /queue clear to abandon the uncertain receipt before submitting a new request if needed. Clearing does not cancel a prompt OpenCode already accepted.

The sidecar directory uses owner-only permissions and contains delivery state. Preserve it when restarting. These local writes support process-restart recovery; they are not a power-loss durability guarantee. See the technical protocol for implementation boundaries.

Native turn identity and limits

Native tagged history and delivered inbox/user IDs provide turn identity without server stamps or prompt fingerprints. Compaction entries do not become user prompts. Identical real prompts and attachments retain distinct IDs. Admitting a queued prompt does not replace the running Taskix context; native delivery activates it. Individual model/tool steps do not complete a turn. A busy native execution can include several promoted users and settles them at its terminal boundary. Taskix stores minimal active context/ownership in native plugin storage for compaction and process-restart recovery.

The remote queue accepts up to 128 prompts / 8 MiB, with 256 KiB per prompt. History reads are limited to twenty pages of 200 native messages within five seconds. Bridge caches retain 4,096 message/alias entries and 8,192 parts / 8 MiB of part text, with active identities pinned as needed. Native turn associations retain IDs rather than full prompt or attachment payloads. These caches do not truncate model input or native history. Sidecar checkpoints limit the delta journal to 4,096 records / 1 MiB between checkpoints. Hot delivery receipts retain 2,048 entries / 1 MiB except active work; older receipts remain in a disk archive for exact retry deduplication. The archive intentionally grows with distinct deliveries; these limits do not cap a session's lifetime.

Taskix keeps up to 64 inactive native-session wrappers. Idle wrappers stop lease timers and check ownership from current context; active owned leases continue renewing and are not evicted just to meet the idle limit.

Validation boundary

The installed OpenCode 2.0.32 headless integration passed locally with native TCP registration, Taskix schema/skills, attachment history and compaction identity. The current production Telegram/Engine/BridgeHub/native-TUI/Taskix chain passed with both tmux and rmux, covering native permissions, multiselect answers and service-component replacement during a pending permission. The broader native TUI control fixture separately covers original terminals, queue/crash recovery, compaction and session replacement. Final acceptance results are recorded in the integration coverage map. Telegram HTTP and provider services are local fixtures; this does not verify live IM accounts or production providers. Earlier Linux ARM64/OpenCode 1.19.3 results are historical 1.x evidence. Native 2.0.32 headless Linux/Windows CI is wired; local macOS validation does not prove a full Linux/Windows IM/TUI chain. Current 2.x and historical 1.x performance measurements state their scopes separately and do not establish a zero-regression claim.

Clone this wiki locally