feat: payload visualization dashboard - #1
Conversation
Add tiktoken-based instrumentation to count tokens per payload component (system prompt, tool definitions, user/assistant/tool messages) after each API call. Extend JSONL token log with breakdown field. New Payload tab in dashboard with stacked area chart (context growth over session) and per-turn stacked bar detail with cached token overlay. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
prbot Review (Claude)Code Review: PR #1 — Payload Visualization DashboardPR: feat: payload visualization dashboard OverviewThis PR adds a payload visualization feature to the Hermes dashboard that shows what goes into each API call: system prompt, tool definitions, user messages, assistant messages, and tool results. It instruments the main agent loop with tiktoken-based token counting, extends the existing JSONL log format, adds a new API endpoint, and builds a canvas-based visualization with stacked area charts and per-turn breakdowns. The design is well-considered — instrumenting at the right point in the pipeline, extending existing formats rather than introducing new storage, and handling backward compatibility with pre-instrumentation data. Strengths
Issues & Suggestions🔴 High Priority
🟡 Medium Priority
🟢 Low Priority / Nits
Security
Test Coverage
SummaryThis is a well-architected feature addition with thoughtful design decisions. The main concerns are: (1) tiktoken should be a declared dependency, (2) the encoding should be cached, (3) dead reasoning-chevron CSS should be removed or deferred, and (4) unit tests should be added for the new Python functions. The visualization code is clean and self-contained. After addressing the high-priority items, this is ready to merge. |
|
@codex review |
prbot Review (Codex)SummaryNice addition overall—the instrumentation plus dashboard tab ties log data back to a visual story. Unfortunately, the current payload accounting isn’t accurate for several common scenarios, which makes the new UI misleading. Fixing the counting bugs below should get the feature over the line. P0/P1 Findings
Test Gaps
Overall VerdictRequest changes. |
…d CSS - Fix Codex Responses mode: classify function_call items as assistant, function_call_output as tool_results (was falling through to user) - Fix ensure_ascii=False in json.dumps to avoid inflated token counts for non-ASCII text - Cache tiktoken encoding on self._tiktoken_enc (was re-created per call) - Initialize _last_payload_breakdown in __init__ - Add logger.debug on tiktoken ImportError - Remove dead reasoning chevron CSS (deferred to message_extras work) - Clarify "estimated" vs "exact" in docstring and DEVJOURNAL Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review ResponseAddressed (P1)Codex Responses mis-bucketing (Codex review) Unicode inflation (Codex review) Encoding re-created every call (Claude review #2)
Addressed (P2 clean wins)Dead reasoning chevron CSS (Claude review NousResearch#7) tiktoken ImportError silent (Claude review #1) "Exact" vs "estimated" language (Claude review NousResearch#4) Deferred (with rationale)
|
prbot Review (Claude)Code Review: PR #1 — Payload Visualization DashboardOverviewThis PR adds a payload visualization feature to the Hermes dashboard. It instruments the main agent loop with tiktoken-based token counting, breaks down API payloads into 5 components (system, tool defs, user, assistant, tool results), logs breakdowns to the existing JSONL file, adds a new API endpoint, and renders an interactive area chart + stacked bar visualization in a new dashboard tab. Verdict: Well-structured feature with clean separation of concerns. A few issues worth addressing before merge. 👍 Strengths
|
| Category | Rating |
|---|---|
| Correctness | ✅ Good — logic is sound, edge cases handled |
| Code Style | ✅ Consistent with existing codebase |
| Performance | |
| Security | |
| Test Coverage | |
| Documentation | ✅ Thorough DEVJOURNAL entry and PR description |
Recommendation: Approve with minor changes — address the logging for swallowed exceptions (NousResearch#3) and consider the JSONL scan performance (#2) before merge. The rest are optional improvements.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10267b6766
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| elif role in ("tool", "function"): | ||
| tool_results_tokens += _count(item) | ||
| else: | ||
| user_tokens += _count(item) |
There was a problem hiding this comment.
Classify Codex payload items by
type before defaulting to user
In codex_responses mode, many normalized input items are shaped as {"type": "function_call"} or {"type": "function_call_output"} (without a role), but this classifier only branches on role and then falls through to the user bucket. As a result, tool-call and tool-result tokens are recorded as user, which makes the new payload breakdown endpoint/dashboard materially inaccurate for Codex sessions even when API usage succeeds.
Useful? React with 👍 / 👎.
prbot Review (Codex)SummaryNice addition: the agent now logs a per-component token estimate per API call and the dashboard exposes a new payload tab with stacked and per-turn views. The implementation is sensible overall and the UI looks polished. I only spotted a few maintainability/perf gaps worth addressing. P0/P1 FindingsNone. P2 Findings
Clean WinsNone. Test Gaps
Overall VerdictApprove. |
…ult (NousResearch#1922) SOUL.md now loads in slot #1 of the system prompt, replacing the hardcoded DEFAULT_AGENT_IDENTITY. This lets users fully customize the agent's identity and personality by editing ~/.hermes/SOUL.md without it conflicting with the built-in identity text. When SOUL.md is loaded as identity, it's excluded from the context files section to avoid appearing twice. When SOUL.md is missing, empty, unreadable, or skip_context_files is set, the hardcoded DEFAULT_AGENT_IDENTITY is used as a fallback. The default SOUL.md (seeded on first run) already contains the full Hermes personality, so existing installs are unaffected. Co-authored-by: Test <test@test.com>
Update all SOUL.md documentation to reflect that it now occupies slot #1 in the system prompt, replacing the hardcoded default identity. Updated pages: - user-guide/features/personality.md — SOUL.md is primary identity, not just a layer - developer-guide/prompt-assembly.md — updated prompt layer order, context files list - guides/use-soul-with-hermes.md — SOUL.md replaces built-in identity - user-guide/configuration.md — updated context files table and directory tree Co-authored-by: Test <test@test.com>
Summary
_build_api_kwargs()in the main agent loop — counts system prompt, tool definitions, user messages, assistant messages, and tool results separatelybreakdowndict added to JSONL token log entries (old entries without it handled gracefully)/api/payload-breakdown?session_id=<id>endpoint in dashboardFiles changed
run_agent.py—_compute_payload_breakdown()method + instrumentation at main loop + breakdown in JSONL entrydashboard/data.py—get_payload_breakdown()functiondashboard/server.py—/api/payload-breakdownroutedashboard/static/index.html— Payload tab UI (area chart, stacked bars, detail view, legend, CSS)DEVJOURNAL.md— feature entryDesign decisions
gpt-4oencoding for exact counts (~3ms overhead), not the rough estimatorNot included (deferred)
message_extrasextension table (DB doesn't store reasoning content today)Test plan
breakdownfield~/.hermes/token_usage.jsonlhas breakdown data🤖 Generated with Claude Code