Skip to content

OpenCode Agent ​

OpenCode is a coding agent that runs in a workflow and that you use from the browser or from the ALIDA chat. The datasets you connect decide what it knows and how it behaves.

OpenCode workflow with MCP services

Before you begin ​

  • An agent gateway key (AGENT_GATEWAY_API_KEY), issued by the platform team. The default model needs it.
  • For GitLab work: a personal access token with api and write_repository scopes, and at least the Maintainer role in the target group. Developer cannot create branches.
  • The numeric ID of the GitLab group for new repositories, shown on the group's page.

Quick start ​

  1. Go to Workflows, create a workflow and open the Designer.
  2. Drag the opencode service (category Agent) onto the canvas.
  3. Optional: connect a Prompt dataset to input-dataset-4, for example service-writer to build ALIDA services.
  4. Click the service and set AGENT_GATEWAY_API_KEY, GITLAB_TOKEN and GITLAB_GROUP.
  5. Save and Run the workflow. Wait for the status RUNNING.
  6. Open the service's exposed URL (port 10001) from its panel. Add /L3dvcmtzcGFjZQ to the URL to open the /workspace project directly.

Check it works: send a message. If the agent answers, the model and the key are configured correctly.

To use the agent from the platform, add it to the chat with the OpenCode protocol.

Push your work

/workspace may not survive a stop or restart of the workflow. Only what is pushed to GitLab is safe.

Parameters ​

ParameterRequiredWhat to set
AGENT_GATEWAY_API_KEYWith OpenRouter models, including the defaultVirtual key for the agent gateway. The real OpenRouter key stays in the gateway.
GITLAB_TOKENFor GitLab workWithout it the agent can chat and edit files, but cannot clone, create or push repositories.
GITLAB_GROUPYesNumeric ID of the GitLab group for new repositories.
GITLAB_HOSTYesGitLab base URL.
GIT_URLNoHTTP(S) URL of a repository to open at start, in /workspace/service.
OPENCODE_MODELNoModel to use. Default: openrouter/meta/muse-spark-1.3-contributor. For another OpenRouter model use openrouter/MODEL_ID.
AGENT_GATEWAY_URLNoAgent gateway endpoint. The default is the in-cluster gateway.
ALIDA_ENABLED_CATEGORIESNoComma-separated subset of skills,tools,data (default: all three). An empty value disables these imports. It does not filter Prompt datasets.
portsToExposeNoLeave the default, port 10001.
CPU / memory limitNoDefaults: 800m and 2 Gi. Raise them if the agent is slow or restarts.

Connect datasets ​

The service has six optional inputs: input-dataset-1 to 3 for MCP URLs, and input-dataset-4 to 6 for files. File datasets are handled according to their category. To create these datasets and choose their category, see Extend an agent with datasets.

CategoryWhat happens
PromptThe whole dataset becomes the agent's configuration, imported into /opencode.
SkillOnly skills/NAME/... folders are imported. Each one must contain SKILL.md.
Tooltools/*.ts, lib/ and a root package.json are imported. Tools must sit directly in tools/.
none / DataCopied to /workspace/data as working data.

Plural forms are accepted. An unknown category stops startup; disabled categories and unreachable datasets are logged and skipped. When two datasets contain the same file, the higher port wins.

Prompt dataset ​

Every item is optional:

text
AGENTS.md        Agent instructions, always loaded
opencode.json    Merged over the image configuration
agents/          Subagents
skills/          Skills, one folder each with SKILL.md
tools/           Custom tools, directly in this folder
lib/             Code shared by the tools
plugins/         Plugins
docs/            Reference material
init.d/          Scaffold copied into new repositories

For the file formats, see the OpenCode documentation on config, agents, skills, tools and plugins.

Use only trusted Prompt datasets

A Prompt dataset is imported completely, including tools, plugins and permissions. It can override the default permissions.

MCP servers ​

Connect a URL dataset to input-dataset-1, 2 or 3. The server is added to the agent even if it does not answer at startup, with a warning in the logs. To use an ADK Agent as a tool, connect its output port here. A2A agent cards are not supported and are skipped.

Good to know ​

  • Default permissions: shell commands are denied except listing /workspace and /workspace/repos; the agent cannot edit /opencode, read .env files or ask interactive questions.
  • Kafka: each release also has a VERSION-kafka variant with a Kafka output-dataset port. Tools receive KAFKA_TOPIC and KAFKA_BOOTSTRAP to publish to it.
  • Tracing to MLflow is automatic: see Observability.

Troubleshooting ​

Open the workflow logs with the show-logs button on the workflow page.

SymptomCheck
The agent does not answer, or the model returns an authentication errorAGENT_GATEWAY_API_KEY and OPENCODE_MODEL.
Unsupported category ...A dataset has a category other than Prompt, Skill, Tool, Data or empty.
... has no importable filesThe dataset is empty, or a Skill dataset has no skills/NAME/SKILL.md.
Tool ... must sit directly in tools/Move the tool into tools/ and shared code into lib/.
A tool or skill is missingThe dataset category, and that paths are relative to the dataset root.
MCP warning about /mcpThe endpoint did not answer at startup. Check the URL.
The agent cannot create or push repositoriesThe GITLAB_TOKEN scopes and your role in GITLAB_GROUP.