Overview
OpenCode agent profiles are Markdown files. Project agents live in.opencode/agents/. User agents live in ~/.config/opencode/agents/.
OpenCode session telemetry uses an in-process TypeScript plugin. The plugin is
installed by observal auth login or observal doctor patch. Agent pulls write
agent profiles and update the Observal lockfile, but they do not embed the
telemetry plugin in each agent file.
The plugin listens to OpenCode session and message events, reads message data
through the OpenCode client API, converts new messages into Observal session
lines, and sends them to Observal.
Supported capabilities
Setup
1. Install the Observal CLI
2. Authenticate
~/.observal/config.json. If OpenCode is detected,
login can install the Observal plugin.
3. Pull an agent into OpenCode
~/.config/opencode/agents/{name}.md.
To install into the current project:
.opencode/agents/{name}.md.
4. Install or refresh the OpenCode plugin
observal-plugin.ts when the plugin is missing, stale,
or different from the bundled source.
Config paths
OpenCode MCP configs use the
mcp key.
Plugin spec
Observal installs a TypeScript plugin namedobserval-plugin.ts. The plugin
subscribes to OpenCode runtime events:
The bundled spec version is checked by
doctor patch, along with the plugin
content hash, so stale local copies are replaced.
Attribution
OpenCode exposes the active agent name in session events, not an Observal UUID. The Observal lockfile maps that OpenCode agent name back to the registry agent id and installed version.observal agent pullwrites the OpenCode agent profile and records the agent name, id, version, scope, and project directory in~/.observal/lockfile.json.- The OpenCode plugin receives
session.createdor agent switch events and reads the active OpenCode agent name. - Built-in OpenCode agents such as
build,plan,general,explore,scout,compaction,title, andsummaryare ignored. - The plugin selects the configured server URL under
registriesin~/.observal/lockfile.json, then searches that registry’sopencodeharness for an entry whosenameoridmatches the active agent. - If multiple entries match, a project-scoped entry for the current directory wins, then a user-scoped entry, then the first match.
- The session payload is sent with the resolved
agent_idandagent_version. - If no lockfile match exists, the plugin skips attribution for that session instead of guessing.
Session push behavior
The OpenCode plugin implements the same acknowledged delivery contract as Python harnesses:- Load
~/.observal/config.jsonand resolve the active agent through~/.observal/lockfile.json. - On
session.idle, recover missing, stale, or quarantined local state from the server’s contiguous checkpoint. - Retry any durable pending batch before reading new messages.
- Fetch messages from
client.session.messagesand convert each message into one stable JSONL-compatible source record. - Atomically persist the pending indexed batch under
~/.observal/opencode_session_outbox/before network delivery. - Retry the same batch idempotently until the server returns a contiguous acknowledgement covering it.
- Advance the persisted source line only after that acknowledgement; a crash after server commit safely retries the batch.
- On finalization, compare a SHA-256 audit manifest and replay from the server-requested repair range when needed.
Agent profile format
OpenCode agents are Markdown files. Observal writes the agent prompt into the profile selected by scope:Caveats
The plugin is shared per OpenCode install. It is installed by auth login ordoctor patch, not by each agent pull.
Attribution depends on the lockfile. If an agent profile is copied by hand
without running observal agent pull, the plugin may see the OpenCode agent
name but have no Observal id or version to send.
Built-in OpenCode agents are ignored. Sessions for built-in agents are not
attributed to registry agents.
MCP config is OpenCode-specific. OpenCode uses opencode.json and the
mcp key, not Kiro or Claude Code MCP paths.
