Turning long AI sessions into a work map: dsh-topic-graph
Split a session into turns, let AI incrementally cluster them into topics and stages, and see at a glance where tokens, tools, and time went. dsh-topic-graph is a Web UI plugin for DeepSeek Harness (dsh) that turns a
Split a session into turns, let AI incrementally cluster them into topics and stages, and see at a glance where tokens, tools, and time went.
-
dsh-topic-graphis a Web UI plugin for DeepSeek Harness (dsh) that turns a long agent session into a navigable work map. - It splits a session into turns, has the model cluster turns into named topics and topics into stages β incrementally, so long sessions don't blow up the context.
- Every topic/stage carries its own token, tool-call, and agent-time stats, so you can see what was expensive and what was slow.
- Three views: workflow (stage β topic tree + details), timeline (turns as an X axis, stages as lanes), and structure graph (topic tree + relation rail).
- Subagent sessions are segmented too and drawn as branches on the same map.
- Recent additions: a settings page (enable/disable the backend service) and bilingual UI (Chinese / English)!
The problem: long sessions are linear, work is not
If you use an AI coding agent for real work, you know the feeling: after a few hundred turns, you can no longer answer the simplest management questions about your own session:
- Where did the work actually go?
- Which part was expensive / slow?
- Where was that conclusion we reached an hour ago?
A chat log is a linear list of messages. But the work is a network: you bounce between features, hit errors, go back, verify, and revisit. Once a session gets long, reconstructing that map from memory and search is a archaeology project.
dsh-topic-graph does that reconstruction for you. It listens to the session event stream, splits the session by turns, and asks the model to incrementally fold turns into topics and topics into stages β with names, summaries, and stats.
Three concepts
The whole plugin is built on a deliberately boring abstraction:
| Concept | What it is |
|---|---|
| Turn | One user message β the assistant's completed reply. The unit of measurement and segmentation. |
| Topic | One continuous line of work, e.g. "implement the login endpoint" or "debug the cache stampede". |
| Stage | A group of adjacent topics that belongs together, e.g. "requirements β implementation β integration". |
Every topic and stage is named and summarized by the model, and carries its token usage, tool calls, and agent time. That's the key difference from a plain "chat summary": it measures effort, not just content.
View 1: Workflow
The main view is Topics Β· Workflow. On the left is a stage β topic tree; on the right is the selected stage's detail.
- Stage tree is collapsible and shows token/time share per stage.
- Stage header shows token usage, wall time, and a tool-call breakdown bar.
- A mini relations diagram shows how the topics inside the stage relate to each other (X = turns, dots = topics, dashed lines = relations).
- Topic cards expand into turn-by-turn detail.
Drill into a turn and you get the token breakdown (input / output / cache read / cache write), step activity time, tool calls, total steps, and the model β plus the user prompt and assistant reply, with a one-click jump to the conversation.
Per-turn AI analysis
Some turns are dense β a messy debugging session, a long investigation. One click turns the turn's model/tool trace into a human-readable, step-by-step explanation, with each step tagged by how many trace steps it covers. The result is cached and can be regenerated.
View 2: Timeline
Switch to Topics Β· Graph and you get the timeline by default: the X axis is turns (time), the Y axis is stages (lanes), and each topic is drawn as a colored bar spanning its turn range.
Semantic relations between topics are drawn as faint dashed curves β subtle by default, highlighted on hover or click. You can read "where did we go back to something" without turning the view into a spider web.
View 3: Structure graph
The structure graph is the stage β topic tree, with a relation rail on the right that draws the relations between topics. Stages collapse, hover shows details, click opens the topic.
The timeline answers "what happened when". The structure graph answers "how does the work fit together". They're complementary, not alternatives.
What it measures
The top bar shows session-level stats β tokens, step time, tools, turns, topics, stages, relations, and the AI segmentation cost β with the segmentation model selector and manual segmentation controls right there.
Each topic, stage, and turn gets three shares:
- Token share β how much of the session's tokens this piece of work burned;
- Tool-call share β how many of the tool calls it accounts for;
- Agent time share β how much wall time it took.
After one "project" in a single session, you can answer directly: which part was most expensive, which was slowest, and which was the most tool-heavy.
Relations between topics
Beyond "what came before what", the plugin identifies semantic relations:
-
nextβ the chronological chain of adjacent root topics; -
belongToβ a topic belongs to a stage / a subtopic belongs to its parent / a subagent topic belongs to a branch; -
has_relationβ model-judged semantic relations (depends on / continues / contrasts / fixes / verifies / revisits β¦), with a label; -
delegatesβ parent topic β subagent branch delegation.
Revisits are the pattern that matters most in long sessions: "we talk about A, move to B, then come back to A". After segmentation, the plugin runs a cheap, title-only relation pass specifically to surface these "we came back" loops.
Subagents on the same map
In dsh, a subagent runs in its own session β easy to lose track of. The plugin segments subagent sessions too and draws them as branches under their parent topic. Multi-level delegation (a subagent spawning another subagent) is supported.
The result: the main agent's and the subagents' tokens and time can be compared on the same map, instead of each session being its own island.
How the segmentation works (the engineering part)
The hard part of "draw a structure over hundreds of turns" isn't the model's intelligence β it's context length and stability. A few things the plugin does:
- Incremental segmentation: when new turns arrive, only the new turn summaries plus the existing topic/stage structure are sent to the model. Historical turn bodies are never re-sent.
- Batching with halving retries: 6 turns per request by default; a failed request halves the batch (6 β 3 β 1) and remembers the working size.
- 400 handling: on 400-class errors it retries with the adapter's default reasoning effort.
- Truncation detection: the output budget scales with topic count; if the structure JSON is truncated, it retries with a larger budget and detects the truncation instead of accepting a half-parsed structure.
- Fast fallback: repeated failures fall back to local rule-based segmentation, so it never burns money retrying forever.
The result is that even a huge session can be imported incrementally, while you watch, instead of waiting for one big request that may fail.
Settings page and bilingual UI (recent)
The plugin adds a Topic Graph page under dsh Settings:
- Backend service on/off β when disabled, automatic segmentation and AI analysis stop (existing data stays viewable); the setting is persisted.
- UI language β Chinese / English / follow dsh, applied instantly.
- AI output follows the language β topic/stage names, relation labels, and per-turn analysis are generated in the selected language (or match the conversation when set to "follow dsh").
Install
Option 1 (recommended): from the dsh-market plugin market
Search for dsh-topic-graph in dsh's plugin market and click Install. Plugin page:
π https://awesome-dsh-plugin.com/p/hagen666/dsh-topic-graph/
Option 2: npm
dsh plugin --profile web add dsh-topic-graph
Option 3: GitHub
dsh plugin --profile web add github:hagen666/dsh-topic-graph
Restart dsh and refresh the page β the Topics view appears right after Chat / Trajectory.
- Repo: https://github.com/hagen666/dsh-topic-graph
- npm: https://www.npmjs.com/package/dsh-topic-graph
- Market: https://awesome-dsh-plugin.com/p/hagen666/dsh-topic-graph/
Final thought
The premise is simple: sessions are written for the AI, but progress is read by humans.
Fold a few hundred turns into a map with stats, relations, and jump-to-turn, and questions that used to require memory β "where are we?", "why did this take so long?", "where was that conclusion?" β become a glance.
If you run long tasks with dsh, give it a try. Issues and ideas are very welcome.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.




