Mlflow
MLflow plugin for opencode - tracks sessions, tool executions, and metrics in your local MLflow server
0
209
近 7 天 9
33.8
生态多维模型
15 天前
2026-09-19
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-mlflow-plugin@1.0.1"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-mlflow-plugin@1.0.1"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-mlflow-pluginOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
OpenCode plugin that sends LLM tracing data to MLflow with full observability: token counts, costs, model info, generation parameters, and GenAI semantic conventions.
What it captures
| Category | Fields |
|---|---|
| Tokens | input, output, reasoning, cache read/write, total |
| Model | model ID, provider, agent name |
| Cost | USD cost per turn |
| Generation | temperature, topP, topK, maxTokens |
| Finish | stop, tool-calls, etc. |
| Request/Response | Full prompt and completion text |
| MLflow metrics | message_count, tool_count, duration_ms |
Setup
- Place
send_trace.pyanddist/in your plugin directory - Add to
opencode.json:
{
"plugin": ["C:/path/to/opencode-mlflow-plugin/dist/index.js"]
}
- Ensure MLflow is running on
http://localhost:5000(or configuretrackingUri)
Options
{
"plugin": [["C:/path/to/dist/index.js", {
"trackingUri": "http://localhost:5000",
"experimentName": "opencode-sessions",
"logSpans": true,
"logTokens": true,
"logToolDetails": false
}]]
}
| Option | Default | Description |
|---|---|---|
trackingUri |
http://localhost:5000 |
MLflow tracking server URL |
experimentName |
opencode-sessions |
MLflow experiment name |
logSpans |
true |
Create MLflow traces with spans |
logTokens |
true |
Capture token counts |
logToolDetails |
false |
Log individual tool execution durations as metrics |
How it works
- Listens to OpenCode events (
chat.message,message.updated,chat.params, tool events) - Accumulates token counts across parallel assistant messages in a turn
- Uses a 2-second debounce to handle multiple assistant messages per turn
- Sends traces to MLflow via a Python subprocess using the MLflow SDK (synchronous mode)
- Creates LLM-type spans with GenAI semantic convention attributes
Requirements
- Python 3.10+ with
mlflowinstalled (pip install mlflow) - MLflow tracking server running
- OpenCode with plugin support
License
MIT
同类生态推荐
Vitals
opencode-vitals
OpenCode V2 plugin that shows session turns, steps, and average streaming tok/s inside OpenCode's own composer
Hard Limit
opencode-hard-limit
OpenCode plugin that hard-stops model calls before you burn through your AI quota. Monitors the 5h or weekly window for Claude and OpenAI, blocks at a configurable percent-remaining threshold, and shows a live usage bar in the sidebar. Set your goal per-p
Hud
opencode-hud
OpenCode plugin that displays TPS, TTFT, and token metrics at conversation end.