@rhythmjnh

Prompt Logger

Logs complete LLM input/output to disk as JSON for debugging

当前版本
v1.0.3
code-plugin社区source-linked
<picture> <source media="(prefers-color-scheme: dark)" srcset="https://clawhub.ai/static/logos/clawhub-white.svg"> <img alt="ClawHub" src="https://clawhub.ai/static/logos/clawhub-color.svg" width="40" height="40" align="left"> </picture>

Prompt Logger

ClawHub

An OpenClaw plugin that records every complete LLM request (system prompt, conversation history, tool calls, responses, token usage) to disk as structured JSON files.

Built for debugging — never wonder what OpenClaw actually sent to the model again.


How it works

The plugin uses Plugin Hooks (model_call_started, llm_output, model_call_ended, agent_end) to capture everything the Gateway sends to the LLM provider.

Output structure

<workspace>/prompts/
├── 2026-05-09.jsonl          # Lightweight index (search with jq/grep)
├── 2026-05-10.jsonl
└── raw/
    ├── 2026-05-09-104212-prompt-a1b2c3d4.json   # Full request
    └── 2026-05-10-091500-prompt-e5f6g7h8.json

JSONL index (quick search)

Each line contains key metadata:

{
  "ts": "2026-05-09T02:42:12.608Z",
  "session": "agent:main:...",
  "model": "custom-provider/model-name",
  "inputTokens": 24072,
  "outputTokens": 70,
  "success": true,
  "rawFile": "raw/2026-05-09-104212-prompt-xxx.json"
}

Raw files (full details)

Each raw file contains the complete agent messages array (system prompt, user messages, assistant replies, tool calls/results) plus LLM usage and timing info.


Installation

openclaw plugin install prompt-logger

Requires OpenClaw Gateway v2026.5.0 or later.

Configuration

Add to openclaw.json:

{
  "plugins": {
    "entries": {
      "prompt-logger": {
        "enabled": true,
        // Required: this plugin uses llm_output/agent_end hooks which
        // need explicit conversation access opt-in (security gate)
        "hooks": {
          "allowConversationAccess": true
        },
        "config": {
          "retentionDays": 30,   // Auto-delete raw files older than N days
          "logInput": true,       // Record full prompt messages
          "logOutput": true       // Record LLM responses
        }
      }
    }
  }
}

⚠️ Important: Without hooks.allowConversationAccess: true, the plugin will load but silently produce no output. This is a Gateway security measure — non-bundled code plugins that access raw conversation content must opt in explicitly.

Query examples

# Find all failed requests today
jq 'select(.success == false)' prompts/2026-05-09.jsonl

# Find requests for a specific model
jq 'select(.model | test("deepseek"))' prompts/2026-05-09.jsonl

# Count total tokens used today
cat prompts/2026-05-09.jsonl | jq -s 'map(.inputTokens + .outputTokens) | add'

# View a specific full prompt
less prompts/raw/2026-05-09-104212-prompt-xxx.json

Disk usage

Each raw file is 100-500 KB depending on conversation length. The JSONL index is negligible (~200 bytes/entry). With retentionDays: 30, old files are cleaned automatically.


Publishing

  1. Create an account on clawhub.ai
  2. Install the clawhub CLI: npm i -g clawhub
  3. Run clawhub login
  4. Publish:
clawhub package publish prompt-logger --dry-run
clawhub package publish prompt-logger

License

MIT

源码与版本

源码仓库

RhythmJnh/prompt-logger

打开仓库

源码提交

dd8a17252714cdbf86f8591553e6f8bb9f40e110

查看提交

安装命令

openclaw plugins install clawhub:prompt-logger

元数据

  • 包名: prompt-logger
  • 创建时间: 2026/05/09
  • 更新时间: 2026/05/09
  • 执行代码:
  • 源码标签: main

兼容性

  • 构建于 OpenClaw: 2026.5.7
  • 插件 API 范围: >=2026.5.0
  • 标签: latest
  • 文件数: 8