💻 Coding Agent (OpenCode)


The OpenCode Coding Agent is a pair-programming AI assistant integrated into OnMyChat. It allows you to run terminal commands, search, edit files, and debug code directly inside your workspace in collaboration with the AI.

Coding Agent in Action


1. Setup OpenCode Web Service

The OpenCode agent runs as a background service on your host or node.

1. Installation

Ensure the opencode binary is installed under your user profile (e.g. ~/.opencode/bin/opencode).

2. Configure Systemd Service

Create the service unit /etc/systemd/system/opencode.service to manage the background daemon:

[Unit]
Description=OpenCode Web Service
After=network.target

[Service]
User=your_username
WorkingDirectory=/home/your_username/projects
Environment="PATH=/home/your_username/.opencode/bin:/usr/local/bin:/usr/bin:/bin"
ExecStart=/home/your_username/.opencode/bin/opencode web --port 4096 --hostname 127.0.0.1
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable --now opencode

2. Model Selection: Local vs. Cloud

The OpenCode agent can run using either cloud-hosted or local language models.

By default, the proxy uses a cloud-based code model for fast response times and superior coding reasoning (e.g. Nemotron-3-Ultra).

In your OnMyChat configuration /opt/onmychat/config.ini:

CLOUD_CODE_MODEL = opencode/Nemotron-3-Ultra

Local Models (Full Privacy)

To run OpenCode completely offline, configure it to run via your local Ollama or RKLLAMA service:

  1. Pull a coding-optimized LLM via Ollama:
    ollama pull qwen2.5-coder:7b
    
  2. Configure OnMyChat config.ini to route coding requests locally:
    # Point to local model
    CODE_MODEL = qwen2.5-coder:7b
    

3. How to Use OpenCode

When the OpenCode integration is enabled, a Code section will appear in the sidebar.

  1. Start or Open a Session: In the Code section, start a new coding session or open a recent one.
  2. Select your Workspace: Within a new coding session, select a recent project or click Select workspace to navigate to your project directory.
  3. Collaborate on Code: You can ask the assistant to write code, make modifications, or run commands. The agent will always request your explicit approval for command execution or file edits before executing them, showing you changes as diffs directly in the chat interface.