You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Persistence View, multi-turn dataset examples, and project hygiene
HTML report: replace Flow tab with Persistence View (heatmap of content
blocks × requests, blue intensity = token cost, COMPACT? annotations).
Flow code retained but hidden; Artifacts pane unchanged.
Multi-turn examples: add SWE-agent, lmcache, OpenHands trajectory demos
with conversion scripts and pre-converted session fixtures. README gains
a Findings Across Public Datasets table (3 datasets, real profiler output).
Project hygiene: remove toolathon fixtures and GIFs; refresh screenshots
to match new views; update CLAUDE.md with accurate architecture, format
strategy, and HTML view names; update skill with missing issue codes;
remove planned OTel from plugin manifests; add .gitignore entries.
Copy file name to clipboardExpand all lines: CLAUDE.md
+29-11Lines changed: 29 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,9 @@ This file guides AI coding agents working on `context-profiler`.
4
4
5
5
## Project Overview
6
6
7
-
`context-profiler` is a trace-source agnostic context analysis harness for LLM agents. It accepts raw provider requests, observability traces, local coding-agent transcripts, and future benchmark trajectories, then reports how context grows, repeats, and concentrates around tools/artifacts.
7
+
`context-profiler` is the evidence layer for context engineering. It accepts raw provider requests, observability traces, and agent trajectories, then reports how context grows, repeats, and concentrates around tools/artifacts — so humans and agents know what to compact and where it's safe to cut.
8
8
9
-
Core boundary: this project analyzes traces. It does not fetch traces, replay agent loops, or execute third-party tools.
9
+
Core boundary: the library and CLI analyze trace files or stdin. Agents may fetch user-requested trace exports with tools such as `curl` before invoking `context-profiler`, but core should not replay agent loops or execute third-party tools.
For new benchmark trajectory formats (SWE-agent, T1, tau-bench, etc.), write conversion scripts in `examples/<dataset>/convert.py` that output OpenAI-format JSONL. Do not add new core adapters for every dataset.
43
61
44
62
## Format and Analyzer Rules
45
63
@@ -51,9 +69,9 @@ PYTHONPATH=src uv run context-profiler analyze tests/fixtures/cursor_transcript.
51
69
52
70
## Product Boundaries
53
71
54
-
Do not add provider-specific fetch clients to core. Agents can use Langfuse public API exports via `curl`, SDKs, Hugging Face tooling, or local transcript discovery to obtain data, then pass files or stdin to `context-profiler`. Prefer direct Langfuse public API exports over `langfuse-cli` for trace analysis because the CLI can omit fields needed for nested observations and generations.
72
+
Do not add provider-specific fetch clients to core. Agents can use Langfuse public API exports via `curl`, SDKs, Hugging Face tooling, or local transcript discovery to obtain data when the user asks, then pass files or stdin to `context-profiler`. Prefer direct Langfuse public API exports over `langfuse-cli` for trace analysis because the CLI can omit fields needed for nested observations and generations.
55
73
56
-
Do not make Toolathlon a first-class multi-turn demo. Prefer genuinely multi-turn datasets such as `pagarsky/agent-trace`, `cx-cmu/agent_trajectories`, and SWE-agent trajectories for future research examples.
74
+
Canonical multi-turn demodatasets are in `examples/`: SWE-agent trajectories (nebius), lmcache-agentic-traces (sammshen), and OpenHands trajectories (nvidia). For new datasets, write conversion scripts in `examples/<dataset>/convert.py` rather than adding core adapters.
Trace-source agnostic context analysis harness for LLM agents.
7
+
The evidence layer for context engineering. Profile before you prune.
8
8
9
-
Bring any agent trace, loop, transcript, or raw provider request. `context-profiler` explains how the context grows, which tools dominate it, what repeats, and where turn-to-turn changes happen.
9
+
`context-profiler` turns raw provider requests, observability exports, and agent trajectories into evidence about how context grows, repeats, and concentrates — so you know **what** to compact and **where** it's safe to cut.
10
10
11
-

11
+
<palign="center">
12
+
<imgsrc="assets/readme/hero.png"alt="context-profiler: Icicle view showing token distribution across a 31-turn SWE-agent session"width="100%">
13
+
</p>
12
14
13
15
## Why
14
16
15
-
Agent systems fail quietly when context grows too large, repeats stale observations, carries verbose tool payloads, or churns on the same artifact for many turns. Observability tools tell you what happened. `context-profiler`focuses on what happened to the context.
17
+
Compression tools (LLMLingua, `/compact`, Mem0) execute blindly. They don't tell you what's redundant, what's safe to remove, or what downstream references will break. `context-profiler`fills the missing step:
16
18
17
-
It is designed for both humans and agents:
18
-
19
-
- Humans get an interactive HTML report with timeline, icicle, diff, and tool views.
20
-
- Agents get stable JSON from `validate`, `diagnose`, and `schema` commands.
21
-
- Skills teach Cursor, Claude Code, and other Agent Skills compatible tools when to call the CLI.
22
-
23
-

24
-
25
-
## What It Finds
26
-
27
-
-**Tool bloat**: tool inputs/results dominate the visible context.
28
-
-**Context growth spikes**: individual turns that add large payloads.
29
-
-**Repeated content**: exact or near-duplicate blocks retained in context.
30
-
-**Repeated tool inputs**: large repeated tool arguments.
31
-
-**Artifact churn**: the same file/component/path appears across many tool calls.
32
-
-**Partial-scope warnings**: transcripts are useful, but not raw provider requests.
33
-
34
-
## Research Context
35
-
36
-
`context-profiler` is motivated by recent work showing that long-horizon agents are constrained not only by model quality, but also by how their working context is retained, compressed, and reused across turns.
19
+
```
20
+
trace → profile → human review → prune/compact decision
21
+
```
37
22
38
-
Related work:
39
-
40
-
-**ByteDance Seed — _Scaling Long-Horizon LLM Agent via Context-Folding_**
41
-
Studies context management for long-horizon agents through folding and summarizing intermediate sub-trajectories. This motivates `context-profiler`'s focus on turn-to-turn context diffs, retained observations, and compression/pruning evidence.
Shows the importance of the agent-computer interface for software-engineering agents, motivating analysis of tool calls, terminal output, and artifact churn.
44
-
-**WebArena — _A Realistic Web Environment for Building Autonomous Agents_**
45
-
Demonstrates the value of realistic multi-step agent trajectories, motivating support for loop/transcript analysis rather than only single prompt snapshots.
• Content duplication: 476 redundant tokens (60.2% of total)
168
+
169
+
Token Distribution
170
+
Category Tokens % of Total
171
+
Total Input 791 100%
172
+
System Prompt 13 1.6%
173
+
Tool Definitions 83 10.5%
174
+
Messages (assistant) 609 77.0%
175
+
Messages (tool) 70 8.8%
176
+
Messages (user) 16 2.0%
177
+
178
+
Top Tools by Token Usage
179
+
generate_canvas_component 595 75.2%
180
+
```
181
+
127
182
## Agent-Friendly CLI Harness
128
183
129
184
`context-profiler` is strict about supported formats but helpful when input does not match. Agents can discover contracts and adapt unsupported traces without asking users to reshape data manually.
@@ -179,16 +234,6 @@ Use `context-profiler formats list --json` for the current machine-readable regi
179
234
180
235
For `agent-transcript`, analysis is intentionally marked `partial`: hidden system prompts, rules, tool definitions, MCP schemas, and provider compaction may not be present.
181
236
182
-
## HTML Report
183
-
184
-
The HTML report is self-contained and keeps the existing profiler style:
-**Context timeline**: growth over turns, with small markers for large additions/tool-input spikes.
188
-
-**Diff mode**: unchanged / added / removed content between requests.
189
-
-**Tools view**: per-tool token table and invocation details.
190
-
-**Detail panel**: selected node or turn-level diff evidence.
191
-
192
237
## Example Diagnosis
193
238
194
239
```json
@@ -239,6 +284,19 @@ Recommended demo order:
239
284
3. Langfuse trace export.
240
285
4. Multi-turn academic trajectories such as `pagarsky/agent-trace`, `cx-cmu/agent_trajectories`, or SWE-agent traces.
241
286
287
+
## Research Context
288
+
289
+
`context-profiler` is motivated by recent work showing that long-horizon agents are constrained not only by model quality, but also by how their working context is retained, compressed, and reused across turns.
290
+
291
+
Related work:
292
+
293
+
-**ByteDance Seed — _Scaling Long-Horizon LLM Agent via Context-Folding_**
294
+
Studies context management for long-horizon agents through folding and summarizing intermediate sub-trajectories. This motivates `context-profiler`'s focus on turn-to-turn context diffs, retained observations, and compression/pruning evidence.
Shows the importance of the agent-computer interface for software-engineering agents, motivating analysis of tool calls, terminal output, and artifact churn.
297
+
-**WebArena — _A Realistic Web Environment for Building Autonomous Agents_**
298
+
Demonstrates the value of realistic multi-step agent trajectories, motivating support for loop/transcript analysis rather than only single prompt snapshots.
0 commit comments