跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    MunhozThiago

    Mlflow

    opencode-mlflow-plugin·v1.0.1·可观测与分析

    MLflow plugin for opencode - tracks sessions, tool executions, and metrics in your local MLflow server

    GitHub 星标

    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"]
    }

    OpenCode 启动时会通过内嵌运行时自动加载 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

    1. Place send_trace.py and dist/ in your plugin directory
    2. Add to opencode.json:
    {
      "plugin": ["C:/path/to/opencode-mlflow-plugin/dist/index.js"]
    }
    
    1. Ensure MLflow is running on http://localhost:5000 (or configure trackingUri)

    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 mlflow installed (pip install mlflow)
    • MLflow tracking server running
    • OpenCode with plugin support

    License

    MIT

    同类生态推荐