feat: add debug trace viewer (picoclaw-tracer)#2945
Open
aruntcet2010 wants to merge 13 commits into
Open
Conversation
Adds a trace viewer tool under tracer/ for inspecting PicoClaw gateway activity in real time. Parses ~/.picoclaw/logs/gateway.log (JSON Lines) and serves a React UI showing per-thread turns, LLM calls, system prompts, messages, available tools, and tool executions. Backend: Go HTTP server (no extra runtime dependencies) Frontend: React + TypeScript + Vite, dark-themed Usage: cd tracer && make build-frontend && go run . Open http://localhost:7331 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Moves tracer logic from package main into the tracer package so it can be imported by the CLI. Adds a cobra subcommand so the trace viewer starts with: picoclaw tracer Flags: --port (default 7331), --log, --frontend-dir Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds cmd/tracer as a self-contained binary entry point with no CGO or heavy picoclaw dependencies. Build and run independently: go build ./cmd/tracer go run ./cmd/tracer Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When the gateway restarts, turn IDs (e.g. main-turn-2) get reused. The parser would then index into a freshly-created empty LLMCalls slice using stale indices from llmIdx, causing a panic. Purge stale llmIdx entries on agent.turn.start when the turn_id already exists, and add bounds checks on the indexing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each tool in Available Tools is now clickable to show the full description and JSON-schema-like parameter definition. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rn label Fix turn list duplication when the gateway restarts with reused turn IDs: only append to the display order on first sighting of a turn_id. Turn list now shows the user message that started the turn as the label, with the raw turn_id shown smaller below it as a secondary identifier. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each LLM call now shows only the messages that were added by this call, not the full conversation history. First call shows just the latest user message; subsequent calls show only the new tool calls/results. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
picoclaw turn IDs skip odd numbers (placeholder turns), which is confusing. Drop them entirely and rely on the user-message label and timestamp instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each turn now shows a single flat Conversation section with all messages in chronological order (user, assistant tool calls, tool results, final assistant). System prompt and available tools are collapsed sections shown once per turn instead of repeated per iteration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each LLM call now renders as a collapsible card showing the full messages array as-sent (system + history + new), with the call's own Available Tools nested inside. Headers show msg count, tools count, response chars, and tool calls at a glance. Also fixes flex layout: minHeight: 0 on the scrollable container and flexShrink: 0 on each LLM card so the parent's overflowY: auto actually triggers instead of squishing cards on top of each other. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Drop `picoclaw tracer` subcommand and its wrapper file so the main picoclaw binary doesn't link the tracer package. Users run the standalone `picoclaw-tracer` binary from cmd/tracer instead. - Delete LLMCallCard.tsx (replaced by inline rendering in TurnDetail). - Stop tracking tsconfig.tsbuildinfo; add it to tracer/.gitignore. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Arun Thulasidharan seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds picoclaw-tracer, a standalone web UI that reads the gateway JSON-Lines log and renders per-turn LLM traces in real time — system prompt, full messages array, available tools, tool executions, and response metadata for every LLM call within a turn.
cmd/tracer— no CGO, no libolm, no picoclaw core imports. Build withgo build ./cmd/tracer.~/.picoclaw/logs/gateway.logfrom disk. Does not talk to the gateway, share state, or affect the picoclaw process in any way. Crashing/removing the tracer has zero impact on picoclaw.cmd/picoclaw/,pkg/) — verifiable withgit diff main..feat/tracer -- cmd/picoclaw/ pkg/returning empty.go:embedbehind a build tag, so a single binary serves the UI. Dev mode reads from disk for hot reload.What it shows
For each turn:
[0] SYSTEM,[1] USER,[2] ASSISTANT,[3] TOOL, ... — captured per-call so you can see when system prompt or tool list changes mid-turnThreads are grouped by
chat_idand chat threads can be browsed in a three-pane layout (threads → turns → detail).Architecture
Running
See
tracer/README.mdfor details on dev mode and the Makefile targets.Test plan
go build ./tracer/... ./cmd/tracer/...succeeds without CGO./picoclaw-traceragainst a populated~/.picoclaw/logs/gateway.logand confirm:[0]git diff main..feat/tracer -- cmd/picoclaw/ pkg/is empty (picoclaw core untouched)🤖 Generated with Claude Code