本文へ移動
cccskills
無料GitHub で公開日本語紹介

agent-tracing

エージェントの実行記録を操作IDから調べ、失敗したツール呼び出し、入出力、LLMに渡した文脈を確認して原因を追えるようにします。

原文原文の説明を見る

Use for agent traces by operation ID (拉线上 tracing): failed tools, arguments/results, available tools, execution location, LLM calls and context.

lobehub/lobehubスター 83,502(GitHub 83,502 + cccskills 0)
連携ツールRedis

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • 失敗したツール呼び出しを調べたいとき
  • LLMに渡された文脈を確認したいとき
  • 操作ごとのツールと結果を追いたいとき
  • 別モデルで記録済みの呼び出しを比較したいとき

日本語での紹介

できること

エージェントの実行スナップショットをCLIで確認し、処理のどの段階で何が起きたかを調べるスキルです。操作IDから実行を開き、ツール呼び出しと結果、LLMに渡したメッセージ、実行時の文脈、利用可能なツール、ユーザーメモリなどを確認できます。開発環境では実行記録が.agent-tracing/に保存され、途中のスナップショットも調査できます。ctx-mapではLLM呼び出しごとの文脈構成や、前回から変化したメッセージ範囲を見られます。記録済みの呼び出しを別モデルに再送する機能もあり、結果を比較できます。

こんなときに便利

エージェントがツールを失敗した理由や、想定した情報がLLMに届いているかを確認したいときに向いています。モデルを変えた場合の応答比較や、長時間の目標実行でどの作業候補が選ばれたかをたどる用途にも使えます。

使い方の例

  • 「この操作IDの実行を開き、失敗したツールと引数、結果を確認してください」
  • 「LLMに渡されたメッセージと利用可能なツールを表示してください」
  • 「この記録済みのLLM呼び出しを別モデルで再生して比べてください」

注意点

CLIはリポジトリのルートから実行します。圧縮スナップショットの読み取りにはNode 22.15以上が必要です。リモートの記録を扱う方法によっては、LobeHubのログイン、認証情報、TRACING_BASE_URLの設定が必要です。リプレイでは記録されていないサンプリング設定は現在の既定値が使われます。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

資料チェック

SKILL.md の記述から、注意が要る操作と導入の前提を AI が確認しました。点数は実際に動かした結果(実行検証)だけで付けています。

安全面送信・削除・コマンド実行などの扱いが明示されているか
B一部不足認証情報やTRACING_BASE_URLを使う場合がありますが、情報の取扱い説明は限定的です。
導入のしやすさ必要なツールや API キーが少ないか、書かれているか
B一部不足Node 22.15以上やLobeHubログイン、環境変数が必要な場合があります。

点数には入れていません。 2026年10月26日 時点で AI(OpenAI Codex)が判定しました。目安なので、入れる前に原文も確認してください。

評価が違うと思ったら、見直しを依頼する

どの項目が、なぜ違うと思うかを書いてください。ログインは不要です。内容を SKILL.md と照らし合わせて評価を作り直し、この欄に反映します。

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

含まれるファイル(1)

  • SKILL.md20.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Agent Tracing CLI Guide

@lobechat/agent-tracing is a zero-config local dev tool that records agent execution snapshots to disk and provides a CLI to inspect them.

How It Works

In NODE_ENV=development, AgentRuntimeService.executeStep() automatically records each step to .agent-tracing/ as partial snapshots. When the operation completes, the partial is finalized into a complete ExecutionSnapshot JSON file.

Data flow: executeStep loop -> build StepPresentationData -> write partial snapshot to disk -> on completion, finalize to .agent-tracing/{timestamp}_{traceId}.json

Context engine capture: In RuntimeExecutors.ts, the call_llm executor calls ctx.tracingContextEngine(input, output, metadata) after serverMessagesEngine() processes messages. AgentRuntimeService.executeStep buffers the call per step and forwards it to OperationTraceRecorder.appendStep as the typed contextEngine field. CE flows through this side channel rather than the events array so its heavy payload (agentDocuments, systemRole, …) never enters the Redis state pipeline (LOBE-9110). metadata carries the pipeline's per-request decision records (trim stats, cache-warmth gates, truncation counts).

Package Location

packages/agent-tracing/
  src/
    types.ts          # ExecutionSnapshot, StepSnapshot, SnapshotSummary
    store/
      types.ts        # ISnapshotStore interface
      file-store.ts   # FileSnapshotStore (.agent-tracing/*.json)
    recorder/
      index.ts        # appendStepToPartial(), finalizeSnapshot()
    viewer/
      index.ts        # Terminal rendering: renderSnapshot, renderStepDetail, renderMessageDetail, renderSummaryTable, renderPayload, renderPayloadTools, renderMemory
    cli/
      index.ts        # CLI entry point (#!/usr/bin/env bun)
      inspect.ts      # Inspect command (default)
      partial.ts      # Partial snapshot commands (list, inspect, clean)
    index.ts          # Barrel exports

Data Storage

  • Completed snapshots: .agent-tracing/{ISO-timestamp}_{traceId-short}.json
  • Latest symlink: .agent-tracing/latest.json
  • In-progress partials: .agent-tracing/_partial/{operationId}.json
  • Downloaded remote snapshots: .agent-tracing/_remote/{operationId}.json
  • FileSnapshotStore resolves from process.cwd() — run CLI from the repo root

Remote Traces (Production / Staging)

Server deployments also upload completed snapshots to object storage (zstd-compressed; the key is stored in agent_operations.trace_s3_key).

Preferred: lh trace op. The server resolves the key and signs the object for the caller's own scope, so a LobeHub login is the only requirement — no TRACING_BASE_URL, no bucket domain, and no SQL to turn a topic id into an operation id:

lh trace op list --topic tpc_xxx # operations of a topic, newest first, with a TRACE column
lh trace op inspect op_xxx_agt_xxx_tpc_xxx_xxxx
lh trace op inspect op_xxx_agt_xxx_tpc_xxx_xxxx -T # tool injection (enabledToolIds, manifests)

TRACE = — in list means no snapshot was recorded for that run (it predates trace upload, or upload was off). A recorded snapshot can still 404 in storage after its retention window.

Backend: the agentTrace lambda router (getSnapshotUrl / listOperations). Note it is blocked for restricted API keys, so these commands need a real session, not a scoped key.

Fallback: the standalone agent-tracing CLI. It has no LobeHub session, so it builds the object URL itself and needs the bucket's public domain configured:

  • env var: TRACING_BASE_URL=https://<bucket-public-domain>/agent-traces
  • or .agent-tracing/.env in the repo root with the same TRACING_BASE_URL=... line

The deployment-specific value is private to each deployment and intentionally not recorded in this repo. Find the operation id by hand first:

SELECT id, trace_s3_key FROM agent_operations WHERE topic_id = 'tpc_xxx';

Either way the snapshot is cached to .agent-tracing/_remote/<opId>.json, and every inspect flag works the same as for local traces.

Implementation: packages/agent-tracing/src/store/loadSnapshot.ts (resolution order: local store → _remote/ cache → injected resolveDownloadUrl → TRACING_BASE_URL) and store/remote-store.ts (URL built as {base}/{agentId}/{topicId}/{opId}.json.zst). Reading a compressed snapshot needs Node >= 22.15.

Goal Trajectories

A goal is one complete goal execution the way an operation is one complete agent execution, so it gets the same trace format one level up: GoalTrajectory : AdvanceSnapshot mirrors ExecutionSnapshot : StepSnapshot. There is no table of advances, exactly as there is no agent_steps table — goal_traces holds one rollup row per goal plus the object key, and the detail lives in the object.

The leaves join back down: an advance records the operationIds it put in flight (on tick.effects[].operationId), so lh trace op inspect <opId> continues from where the goal trace stops.

agent-tracing goal               # list local goal trajectories
agent-tracing goal goal_xxx      # the run: triggers, outcomes, graph, gates, ops
agent-tracing goal goal_xxx -a 3 # one advance in full, with the frontier it ranked
agent-tracing goal goal_xxx -j   # raw JSON

What each tick records is the decision input, not just the result: the graph it read (as a delta against the previous tick), the budget it evaluated, the responsible task's state, and every eligible work node including the ones it passed over. Without the losers a trace cannot answer "why not that node".

Storage follows the operation switch, so a deployment that keeps one keeps the other:

  • Completed: goal-traces/{goalId}.json.zst
  • In progress: goal-traces/_partial/{goalId}.json.zst (an unfinished long-horizon goal is the normal thing to inspect)
  • Dev: .goal-tracing/{goalId}.json

Replay. replayGoalAgainstCurrentCoordinator(trajectory) re-runs the real decideNextMove over the recorded inputs and reports {advanceSeq, tickIndex, field, recorded, replayed} wherever the current coordinator would now choose differently. This reproduces the coordinator's decisions exactly; it says nothing about whether the dispatched work would have gone the same way.

Implementation: packages/agent-tracing/src/goal/, recorded through apps/server/src/services/goal/advanceGoal.ts (the single funnel every advance passes through) via the onDecision side channel on GoalService.tick.

CLI Commands

All commands run from the repo root:

# View latest trace (tree overview, `inspect` is the default command)
agent-tracing
agent-tracing inspect
agent-tracing inspect <traceId>
agent-tracing inspect latest

# List recent snapshots
agent-tracing list
agent-tracing list -l 20

# Inspect specific step (-s is short for --step)
agent-tracing inspect <traceId> -s 0

# View messages (-m is short for --messages)
agent-tracing inspect <traceId> -s 0 -m

# View full content of a specific message (by index shown in -m output)
agent-tracing inspect <traceId> -s 0 --msg 2
agent-tracing inspect <traceId> -s 0 --msg-input 1

# View tool call/result details (-t is short for --tools)
agent-tracing inspect <traceId> -s 1 -t

# View raw events (-e is short for --events)
agent-tracing inspect <traceId> -s 0 -e

# View runtime context (-c is short for --context)
agent-tracing inspect <traceId> -s 0 -c

# View context engine input overview (-p is short for --payload)
agent-tracing inspect <traceId> -p
agent-tracing inspect <traceId> -s 0 -p

# View available tools in payload (-T is short for --payload-tools)
agent-tracing inspect <traceId> -T
agent-tracing inspect <traceId> -s 0 -T

# View user memory (-M is short for --memory)
agent-tracing inspect <traceId> -M
agent-tracing inspect <traceId> -s 0 -M

# Raw JSON output (-j is short for --json)
agent-tracing inspect <traceId> -j
agent-tracing inspect <traceId> -s 0 -j

# List in-progress partial snapshots
agent-tracing partial list

# Inspect a partial (use `inspect` directly — all flags work with partial IDs)
agent-tracing inspect <partialOperationId>
agent-tracing inspect <partialOperationId> -T
agent-tracing inspect <partialOperationId> -p

# Clean up stale partial snapshots
agent-tracing partial clean

# Map the context window composition of every LLM call (cm / map are aliases)
agent-tracing ctx-map
agent-tracing ctx-map <operationId|traceId|path.json>
agent-tracing ctx-map --html            # standalone report under .agent-tracing/_reports/
agent-tracing ctx-map --html out.html

# Re-issue a recorded LLM call against other models (see "replay" below)
agent-tracing replay <operationId|traceId|path.json>
agent-tracing replay <target> -s 4 -m openai/gpt-5,anthropic/claude-sonnet-5
agent-tracing replay <target> --all-steps

replay — Re-issue a Frozen Call

A snapshot already freezes everything one LLM call saw: steps[].contextEngine.output is the exact message array sent to the model, context.payload.tools the toolset it could reach. replay sends that frozen payload back out with only the model swapped, so a difference in output is attributable to the model rather than to context assembly. If every model fails the same payload, the context is at fault; if some pass, it is model selection.

Available from both CLIs — agent-tracing replay (reads LOBEHUB_JWT) and lh trace op replay (uses the lh login session). Both need credentials because the call goes out through the LobeHub chat route.

# One call: defaults to the last call_llm step and the model the op ran on
lh trace op replay <operationId>
lh trace op replay <operationId> -s 4 -m openai/gpt-5,anthropic/claude-sonnet-5
lh trace op replay <operationId> --judge "answers with a concrete file path"

# Every call of the operation
lh trace op replay <operationId> --all-steps
lh trace op replay <operationId> --all-steps --concurrency 8

--all-steps answers the question the whole feature exists for: take a run that succeeded, put another model on it, and see whether that model also gets the job done. It ends in a PASS / FAIL verdict from an llm-rubric judge comparing the replayed outcome against the recorded one; pass --judge "<criteria>" to define success yourself instead of using the default rubric.

The judge scores the outcome, not the route. A model that solved the same problem by calling different tools has passed. The per-call tool comparison (toolSignature) is reported underneath as supporting evidence — where the run took another path — and never decides pass / fail. A final call that never reached the model is a FAIL, not a missing verdict.

Each call is replayed independently, against the payload the harness actually built for it, so a different answer at call 2 cannot contaminate call 4, a call that fails to reach the provider costs only itself, and the calls go out concurrently (4 at a time by default).

Chaining the nodes — feeding each replayed output into the next — was built and then removed. A trace cannot regenerate tool output, only hand back what was recorded, so the moment the model deviates there is no ground truth left; the run then measures nothing while still looking like it succeeded. Independent replay is the design, not a fallback.

Known limitation: sampling parameters are not recorded. The recorder stores the runtime step context under context.payload, not the provider request body, so temperature, top_p, max_tokens, penalties and reasoning config are absent from every trace written so far. Replays use the server's current defaults for those. Model-to-model comparisons stay valid (every target gets the same request); comparisons against the recorded output do not, for an operation that ran with non-default settings. --temperature / --max-tokens override explicitly. The CLI prints a note line whenever a replay is running without recorded parameters.

ctx-map — Context Window Composition

ctx-map renders one row per call_llm step: the messages that call sent to the model, split into typed segments (system / injected block / user / reasoning / tool call / tool result) with width proportional to tokens, laid against the model's context window.

The second axis is what ctx-lint cannot show: each row is diffed against the previous call, so the longest identical message prefix — the part a provider's prefix cache can reuse — is marked, along with the first message that mutated and the tokens re-processed behind it. A small injected block carrying a relative timestamp (1m ago → now) invalidates every token after it, which shows up as a break marker early in the row.

Reading a row:

  • Block colors encode role directly: orange system, green user, blue assistant, gray tool. Assistant reasoning, content, and tool calls use different steps of the same blue scale; framework-injected blocks use a lighter orange than the system prompt. Every value is a step index into a LobeHub scale vendored in viewer/contextMapScales.ts, with assignments in viewer/contextMapPalette.ts. The HTML report ships both themes and follows the system theme.
  • Neutral message frames group segments that belong to the same payload message. Every role uses the same frame color: the outline communicates structure only, while the block fill carries role and subtype semantics. The original framed layout uses padding inside each message and a small track gap between messages, keeping each payload message visually distinct.
  • Fill says whether the provider reused it: shaded ▓ (HTML: 60%-opaque hatch) was served from the prefix cache; solid █ (HTML: flat) was re-processed by the model.
  • The line under the track is the cache ledger — a bracket / green band spanning exactly the cached prefix, then the break marker (▲ in the terminal, a red rule through the track in HTML) at the column where reuse stopped, with the reason and the re-processed tokens.
FlagShortDescription
--html [path]Standalone HTML report (hover a segment for its content)
--width <n>-wTrack width in terminal columns
--window <n>Override the model context window used as the track
--full-windowAlways scale to the full window, never to the largest call
--json-jPer-call segments + cache stats

The track scales to the context window; when the window dwarfs the payloads (a 50k payload on a 1M window) it falls back to the largest call so the composition stays readable, and the header says which basis is in use. Analysis lives in analysis/contextMap.ts and is exported as buildContextMap() for downstream corpus work.

Inspect Flag Reference

FlagShortDescriptionDefault Step
--step <n>-sTarget a specific step—
--messages-mMessages context (CE input → params → LLM payload)—
--tools-tTool calls & results (what agent invoked)—
--events-eRaw events (llm_start, llm_result, etc.)—
--context-cRuntime context & payload (raw)—
--system-role-rFull system role content0
--envEnvironment context0
--payload-pContext engine input overview (model, knowledge, tools summary, memory summary, platform context)0
--payload-tools-TAvailable tools detail (plugin manifests + LLM function definitions)0
--memory-MFull user memory (persona, identity, contexts, preferences, experiences)0
--diff <n>-dDiff against step N (use with -r or --env)—
--msg <n>Full content of message N from Final LLM Payload—
--msg-input <n>Full content of message N from Context Engine Input—
--json-jOutput as JSON (combinable with any flag above)—

Flags marked "Default Step: 0" auto-select step 0 if --step is not provided. All flags support latest or omitted traceId.

Typical Debug Workflow

# 1. Trigger an agent operation in the dev UI

# 2. See the overview
agent-tracing inspect

# 3. List all traces, get traceId
agent-tracing list

# 4. Quick overview of what was fed into context engine
agent-tracing inspect -p

# 5. Inspect a specific step's messages to see what was sent to the LLM
agent-tracing inspect TRACE_ID -s 0 -m

# 6. Drill into a truncated message for full content
agent-tracing inspect TRACE_ID -s 0 --msg 2

# 7. Check available tools vs actual tool calls
agent-tracing inspect -T      # available tools
agent-tracing inspect -s 1 -t # actual tool calls & results

# 8. Inspect user memory injected into the conversation
agent-tracing inspect -M

# 9. Diff system role between steps (multi-step agents)
agent-tracing inspect TRACE_ID -r -d 2

Key Types

interface ExecutionSnapshot {
  traceId: string;
  operationId: string;
  model?: string;
  provider?: string;
  startedAt: number;
  completedAt?: number;
  completionReason?:
    'done' | 'error' | 'interrupted' | 'max_steps' | 'cost_limit' | 'waiting_for_human';
  totalSteps: number;
  totalTokens: number;
  totalCost: number;
  error?: { type: string; message: string };
  steps: StepSnapshot[];
}

interface StepSnapshot {
  stepIndex: number;
  stepType: 'call_llm' | 'call_tool';
  executionTimeMs: number;
  content?: string; // LLM output
  reasoning?: string; // Reasoning/thinking
  inputTokens?: number;
  outputTokens?: number;
  toolsCalling?: Array<{ apiName: string; identifier: string; arguments?: string }>;
  toolsResult?: Array<{
    apiName: string;
    identifier: string;
    isSuccess?: boolean;
    output?: string;
  }>;
  messages?: any[]; // DB messages before step
  context?: { phase: string; payload?: unknown; stepContext?: unknown };
  events?: Array<{ type: string; [key: string]: unknown }>;
  contextEngine?: {
    input?: unknown; // contextEngineInput minus messages + toolsConfig (reconstructible from baseline)
    output?: unknown; // processed messages array (final LLM payload)
    metadata?: unknown; // pipeline decision records (trim stats, cache gates, truncation counts)
  };
}

--messages Output Structure

When using --messages, the output shows three sections (if context engine data is available):

  1. Context Engine Input — DB messages passed to the engine, with [0], [1], ... indices. Use --msg-input N to view full content.
  2. Context Engine Params — systemRole, model, provider, knowledge, tools, userMemory, etc.
  3. Final LLM Payload — Processed messages after context engine (system date injection, user memory, history truncation, etc.), with [0], [1], ... indices. Use --msg N to view full content.

Integration Points

  • Recording: apps/server/src/services/agentRuntime/AgentRuntimeService/executeStep/index.ts — in executeStep(), after saveAndPublishStep builds stepPresentationData, writes partial snapshot in dev mode
  • Context engine capture: apps/server/src/modules/AgentRuntime/RuntimeExecutors.ts — in call_llm executor, after serverMessagesEngine() returns, calls ctx.tracingContextEngine(input, output, metadata). AgentRuntimeService.executeStep buffers it per step and passes it to traceRecorder.appendStep as the typed contextEngine field (kept off the events array to stay out of Redis state).
  • Store: FileSnapshotStore reads/writes to .agent-tracing/ relative to process.cwd()

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

acceptance

無料概要あり

実際の製品を操作して、利用者が確認できる動作証拠を集め、検証計画に沿った受け入れレポートとして公開するスキルです。

  • 変更後の製品動作を実地で検証したいとき
  • 画面キャプチャなどの証拠を集めたいとき
  • 検証計画とレポートを作成したいとき
lobehub/lobehub8.4万2026年10月26日 更新

add-model-provider

無料概要あり

LobeHubにAIモデルプロバイダーを追加し、実行時連携からモデル表示、設定、ブランド表記、文書化、動作確認まで進めるスキルです。

  • 新しいAIモデルプロバイダーを追加したいとき
  • プロバイダーの設定手順や説明文を更新したいとき
  • 既存プロバイダーへのモデル追加要件を見極めたいとき
lobehub/lobehub8.4万2026年10月26日 更新

add-setting-env

無料概要あり

ユーザー設定の初期値をサーバー側の環境変数で切り替えるため、型定義や設定の組み立て、ユーザーストアへの反映、環境変数の例と説明書きを追加する手順です。

  • 設定の初期値を環境変数で変えたいとき
  • 設定項目をサーバー設定に追加したいとき
  • 環境変数の例と説明を更新したいとき
lobehub/lobehub8.4万2026年10月26日 更新

agent-runtime-hooks

無料概要あり

エージェント実行中の各段階をフックで監視し、ツール呼び出しの模擬・制御や人の承認、圧縮、サブエージェント処理に介入する仕組みを扱います。

  • エージェントの実行状況を記録したいとき
  • ツール結果をテスト用に模擬したいとき
  • Webhookでツール実行を許可・拒否したいとき
lobehub/lobehub8.4万2026年10月26日 更新

agent-signal

無料概要あり

イベントを起点にエージェントのバックグラウンド処理を組み立て、ソース・シグナル・アクション・ポリシーの役割分担や非同期連携を実装するためのスキルです。

  • イベント起点の処理を追加したいとき
  • バックグラウンド処理を非同期化したいとき
  • 重複実行を防ぐ仕組みを整えたいとき
lobehub/lobehub8.4万2026年10月26日 更新

agent-testing-bot

無料概要あり

DiscordやSlackなどの実際のチャットアプリでボットにメッセージを送り、応答を画面で確認する受け入れテストを行うスキルです。

  • 実際のDiscordでボット応答を確かめたいとき
  • SlackやTelegramの会話経路をテストしたいとき
  • macOSアプリ上の操作結果を画面で記録したいとき
lobehub/lobehub8.4万2026年10月26日 更新

lobehub のスキルをすべて見る

このスキルの問題を報告する