跳到正文
cccskills
免费在 GitHub 公开中文介绍

agent-tracing

按操作编号检查智能体运行记录,查看失败的工具调用、参数与结果、运行上下文及传给大语言模型的内容;还可查看上下文映射,并用其他模型重放记录以便比较。

原文查看原文说明

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

lobehub/lobehub星标 83,504(GitHub 83,504 + cccskills 0)
集成工具Redis

实测评分 未实测

查看安装方法

适用场景

  • 排查失败的工具调用
  • 确认传给大语言模型的上下文
  • 按操作追踪工具及结果
  • 比较不同模型的重放结果

中文介绍

功能

此技能通过命令行界面检查智能体的运行快照,帮助你了解每个处理阶段发生了什么。输入操作编号即可打开一次运行记录,查看工具调用及其结果、传给大语言模型的消息、运行时上下文、可用工具和用户记忆。在开发环境中,快照会保存在 .agent-tracing/,运行尚未结束时产生的部分快照也可以检查。ctx-map 会展示每次大语言模型调用的上下文由哪些内容组成,以及与上一次调用相比哪些消息范围发生了变化。你也可以将已记录的调用交给其他模型重放,并比较结果。

适用场景

想查明智能体的工具调用为何失败,或确认预期信息是否传到了大语言模型时,可以使用此技能。它也适合比较不同模型的响应,以及追踪长时间目标执行中选中了哪些工作候选项。

使用示例

  • “请打开这个操作编号对应的运行记录,查看失败的工具、参数和结果。”
  • “请显示传给大语言模型的消息,以及当时可用的工具。”
  • “请用另一个模型重放这次已记录的大语言模型调用,以便比较结果。”

注意事项

请在代码仓库根目录运行命令行界面。读取压缩快照需要 Node 22.15 或更高版本。访问远程记录的方式不同,可能需要登录 LobeHub、提供认证信息并配置 TRACING_BASE_URL。重放时,未记录的采样设置会采用当前默认值。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

文档检查

AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。

安全性发送数据、删除文件、执行命令等是否有说明
B部分不足访问远程记录可能使用认证信息和 `TRACING_BASE_URL`,但相关处理说明有限。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足可能需要 Node 22.15 以上版本、LobeHub 登录或环境变量。

不计入评分。 由 AI(OpenAI Codex)于 2026年10月26日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(1)

  • SKILL.md20.7 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

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

免费有简介

通过实际操作产品验证交付内容,记录用户可查看的证据,并发布验收报告。可检查已有验证计划或创建检查项,选择合适的操作界面,并使用 `lh` CLI 发布结果。

  • 实际检查更改后的产品行为
  • 收集截图或其他验证证据
  • 编写验证计划和报告
lobehub/lobehub8.4万2026年10月26日 更新

add-model-provider

免费有简介

本技能指导在 LobeHub 中接入 AI 模型提供商,涵盖运行时、模型信息、设置、品牌展示、文档和验收,并帮助判断新增模型是否需要新的提供商集成。

  • 为 LobeHub 接入新的 AI 模型提供商
  • 更新提供商设置说明或介绍
  • 判断添加模型是否需要新的提供商集成
lobehub/lobehub8.4万2026年10月26日 更新

add-setting-env

免费有简介

本技能指导如何用服务器端环境变量设置用户偏好默认值,涵盖变量校验、服务器配置、写入用户状态,以及更新 `.env.example` 和自托管文档。

  • 通过环境变量设置用户偏好默认值
  • 将设置接入服务器配置和用户状态
  • 更新环境变量示例及文档
lobehub/lobehub8.4万2026年10月26日 更新

agent-runtime-hooks

免费有简介

说明如何在智能体执行步骤、工具调用、人工审批、上下文压缩和子智能体调用时注册钩子。钩子可观察事件、模拟本地工具结果,也可通过 Webhook 按配置策略允许或拒绝工具调用。

  • 记录智能体步骤和错误
  • 测试时模拟工具结果
  • 通过 Webhook 允许或拒绝工具调用
lobehub/lobehub8.4万2026年10月26日 更新

agent-signal

免费有简介

此技能用于为智能体设计事件驱动的后台工作流,划分来源、信号、动作和策略的职责,并处理异步交接、去重、执行范围、完成记录与运行观测。

  • 添加事件触发的后台任务
  • 将工作移出对话请求
  • 防止动作重复执行
lobehub/lobehub8.4万2026年10月26日 更新

agent-testing-bot

免费有简介

本技能在 macOS 桌面聊天应用中测试机器人频道:打开应用、进入频道或联系人、发送消息、等待回复并截图。支持 Discord、Slack、Telegram、微信、飞书和 QQ;iMessage 使用 BlueBubbles 桥接。

  • 检查真实 Discord 频道中的机器人回复
  • 测试 Slack 或 Telegram 的对话流程
  • 记录 macOS 应用中的操作结果
lobehub/lobehub8.4万2026年10月26日 更新

查看 lobehub 的全部技能

报告此技能的问题