Skip to content

feat: add OpenCode agent profile - #124

Merged
dustinblack merged 1 commit into
mainfrom
feat/opencode-profile
Aug 18, 2026
Merged

dustinblack merged 1 commit into
mainfrom
feat/opencode-profile

Conversation

@dustinblack

Copy link
Copy Markdown
Owner

Summary

Adds OpenCode (formerly sst/opencode) as a supported agent in the dashboard.

Profile Details

  • Install: opencode-ai npm package
  • Resume: opencode --continue
  • OTLP: Traces and logs via OTEL_EXPORTER_OTLP_ENDPOINT (no metrics)
  • MCP: Detected from ~/.opencode/config.json
  • Permissions: Tool approval prompts detected
  • Providers: Anthropic, OpenAI, Gemini, Copilot, Bedrock, Groq, Azure, Vertex, OpenRouter, XAI

Known Limitations

  • No OTLP metrics: Token usage, cost, and activity counters are not exported. Dashboard cards show model and activity from span attributes but no token/cost data.
  • Hardcoded service.name: OpenCode ignores OTEL_SERVICE_NAME and hardcodes it to "opencode" (#25839). Agent ID resolution falls back to tool-type matching. Multiple simultaneous OpenCode sessions may have telemetry routing issues.

Code Changes

  • agent/profiles/opencode.yaml — new profile
  • agent/host_daemon.py:
    • Added "opencode" to _resolve_agent_id() fallback hints
    • Added _merge_missing_keys() for deep-merge of nested spawn_settings (OpenCode's config uses {"experimental": {"openTelemetry": true}})
  • agent/tests/test_host_daemon.py — 5 new tests (agent ID resolution + deep merge)

Testing

95 unit tests passing.

Add support for OpenCode (anomalyco/opencode) as a dashboard agent.
OpenCode is an open-source AI coding agent with multi-provider
support (Anthropic, OpenAI, Gemini, Copilot, Bedrock, etc.).

Profile configuration:
- Install via npm (opencode-ai package)
- Session resume via --continue flag
- OTLP traces and logs enabled via OTEL_EXPORTER_OTLP_ENDPOINT
- MCP server detection from ~/.opencode/config.json
- Permission prompt detection for tool approval dialogs
- spawn_settings patches experimental.openTelemetry into config

Known limitations:
- OTEL_SERVICE_NAME is hardcoded to 'opencode' in the CLI
  (anomalyco/opencode#25839). Agent ID resolution falls back
  to tool-type matching in _resolve_agent_id().
- No OTLP metrics export — token usage, cost, and activity
  counters are not available. Dashboard cards show model and
  activity from span attributes but no token/cost data.

Also includes:
- _merge_missing_keys(): Deep-merge for spawn_settings to
  support nested JSON config (e.g. experimental.openTelemetry).
  Replaces the flat key-only check that couldn't handle
  nested dicts. Backward compatible — flat keys work as before.
- OpenCode fallback in _resolve_agent_id() for the hardcoded
  'opencode' service.name.
- 5 new unit tests (agent ID resolution + deep merge).

Co-authored-by: Claude [email protected]
@dustinblack
dustinblack merged commit 7a6fb1d into main Aug 18, 2026
10 checks passed
@dustinblack
dustinblack deleted the feat/opencode-profile branch August 18, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant