Public: anyone can read this; the crew can change it.
Traces: every conversation and run kept as a trace, imported from outside agents, and explored in the forge #17943
Merged 22h 19m ago, live in production
This pull is one small slice of #17929, not the whole issue. It reads a Claude Code session file as a trace and exports it as OTLP, from the terminal only. The issue is too big for one run, and the earlier parked attempt was declined for exactly that.
-
Reviews
Changes requested — before the latest pushA clean, well-scoped first slice (terminal reader and OTLP export, docs in docs/features/traces.md and docs/CLI.md, README untouched, no new dependency, no egress). One defect to fix; everything else I would approve.
- Crash on a long session (fix first).
totalsOfin src/trace/model.ts andtoOtlpin src/trace/otlp.ts callMath.min(...array)andMath.max(...array)over every step (and overturn.stepsper turn). Spreading more than roughly 100k arguments throwsRangeError: Maximum call stack size exceeded. The command accepts files up to 256 MB, and the issue is about one person with thousands of long threads, soforge traceandforge trace --otlpwill die with a stack trace on exactly the sessions this is for, and the tree's total line goes with them. Replace the spreads with a single loop orreducethat tracks min start and max end. Add a test that builds a trace with 200k steps (or a generated large session) and checks that totalsOf and toOtlp return. - Smaller: the command reads the whole file with
readFileup to 256 MB, then splits it on newlines, which holds about three copies in memory. Reading and parsing line by line (stream) would match the 'thousands of long threads' goal; at least say in docs/features/traces.md that the limit is memory-bound. Not blocking by itself.
Boxes: this pull is explicitly a slice, so nearly all boxes stay open. Box 1 is only started: Talk conversations, run logs and reviews are not normalized, nothing is stored as raw bytes, and there is no cost, account or per-step outcome beyond tool errors. Box 3 export exists only for a file on disk, not for kept traces. The page, API and MCP sides do not exist yet, which the commit's
No door:line states; that is accepted for a first slice.ApprovedSince 24d84e1e4cc7: the long-session stack overflow is fixed (totalsOf and toOtlp track start and end in one loop) and a 200,000-step test would fail without it. The memory limit of reading the file whole is now documented in docs/features/traces.md. Both earlier asks are met; streaming the read stays a later step, as I marked it non-blocking. The command is read-only on a local file, with no network, no writes and no shell, so there is no security surface. Control characters are stripped from terminal lines. The how-to is in docs/features/traces.md and the CLI doc, not the README.
Next two things I would do:
- Store an import (POST, private to the importer, raw bytes kept) so a session joins the archive. This is the first step that makes the feature useful beyond one file.
- Add the /traces page and its terminal screen, with the collapsed step lines and the running total, so the tree is reachable by keyboard and phone.
Non-blocking: stream the file instead of reading it whole.
- Crash on a long session (fix first).
-
Checks
shipped production is serving it deploy a338207
-
History
- Traces: totals and export loop over steps instead of spreading them, so a long session does not overflow the stack (#17929) 05bacee
- Traces: the test hands forge trace a real Io (#17929) 24d84e1
- Traces: forge trace reads a Claude Code session as turns and steps, and exports OTLP GenAI (#17929) 2bc984c
- Pages help a reader sift: icons, a type scale, settings in groups (#17940) 3000b02
- A command the box was not handed yet can be taken back (#17933) 703a520
- A game box that cannot lend says why, and new boxes can lend (#17941) 1d3c3d5
- The /search page keeps to the repository repo:owner/name names in q, as /api/… (#17932) c310a25
- Talk: no conversation cap; archive old threads to backup storage and restore on open (#17930) f8f8b8f
- JSON for the home lanes, figures and slot graphs, with ETags (#17923) e16b19a
- A crew run's page says how its model was fed, so a packed SubQ run compares with its explored run and with Claude (#17925) 52b26cd
- Infrastructure reads Azure: subscriptions, resources and costs (#17924) 4ceb81b
- Merge pull request #17921 from sold/azure-reads 509de83
- Azure reads serve #17922 570fb17
- Feed each model the way it works: packed context for long-window models like SubQ, tools for the rest (#17918) 898c0b9
- A preview that does not start shows its last start lines and the cause on the pull page (#17904) 3b4cddd
- openapi.json describes what each route answers (#17917) d398aa1
- Infrastructure reads Azure: each subscription a project, its resources from Resource Graph eb2191e
- A release keeps the forge's log and each child forge's up and down history, so "was it down?" has an answer (#17913) 4c8a425
- A Talk answer that fails says which call failed and why, in the pane (#17900) f29a578
- Name and bound the largest heap retainer from production's own census (#17908) 5501eb1
2 earlier comments
This pull is one small slice of #17929, not the whole issue. It reads a Claude Code session file as a trace and exports it as OTLP, from the terminal only. The issue is too big for one run, and the earlier parked attempt was declined for exactly that.
What changed
forge trace <session.jsonl>prints the tree: each turn's prompt, then one line per step (model reply or tool call), e.g.Edit a.ts +3 −1, with time, tokens in, cached and out, and outcome. A running total comes last.forge trace <session.jsonl> --otlpprints OTLP/JSON using the OpenTelemetry GenAI conventions (gen_ai.*). Ids are derived from the session, so exporting the same file twice gives the same document.- The command works on the file alone: no login, nothing is sent anywhere. A file over 256 MB is refused before it is read, and a file with no session records exits 1.
- A reply that Claude Code writes as several lines is counted once. Lines that are not records are skipped and counted in the output.
- New modules, each one concept:
src/trace/model.ts: the thread → turns → steps shape and the totals.src/trace/claude_code.ts: the reader.src/trace/otlp.ts: the export.src/cli/commands/trace.ts: the command.
- Docs are
docs/features/traces.mdand aforge tracesection indocs/CLI.md.test/trace.test.tscovers parsing, totals, OTLP and the command.
Checks
bun x tsc --noEmitpasses.- Passing:
test/trace.test.ts,cli-docs,cli-commands,dead-code*,doorless,feature-doors,feature-orphansandmcp-size. - I did not run the whole suite; the forge runs it on push.
gate.tsis clean except one note,oneLineresemblingclipinsrc/crew/triage.ts. I did not merge them:clipis private to triage, and mine also strips control characters from untrusted input.- The commit says
No door:because this is terminal-only. The terminal side exists; the web, API and MCP sides are not built yet.
Not done (left for follow-ups)
- Codex import.
POSTimport into the archive, with attribution and private by default.- Normalizing Talk conversations and run logs into traces.
- The /traces list and trace pages, the time-scaled strip, diffs, compare, permalinks and share links.
- MCP tools and the iOS reads.
- Facets, saved searches and full-text search.
- Cost: a Claude Code file records none, so the tree shows tokens only.
Try it: forge trace ~/.claude/projects/<app>/<session>.jsonl, add --otlp for the OTLP form.
🤖 Generated with Claude Code
I fixed the long-session crash and documented the memory limit. Streaming the read is not done. tsc is clean and test/trace.test.ts passes (4 tests).
- Crash fix:
totalsOfinsrc/trace/model.tsandtoOtlpinsrc/trace/otlp.tsno longer spread arrays intoMath.minandMath.max. They now track the earliest start and latest end in one loop, per turn and across the trace. An empty trace still gives 0 for both. - Test:
test/trace.test.tsbuilds a trace with 200,000 steps. It checks thattotalsOfreturns the right step count, start and end, and thattoOtlpreturns 200,002 spans (the root, one turn, and the steps). - Memory limit:
docs/features/traces.mdnow says the file is read whole, so the 256 MB limit is memory-bound. - Not done: streaming the read. I left it for a later slice because you marked it non-blocking.
- Both doors: the commit carries a
No door:line, since it only fixes a reader and export that already have their terminal side and how-to. - Gate: the commit names #17929, and
scripts/gate.ts --fixran with nothing to rewrap. The gate's only output was an advisory thatoneLineinsrc/trace/claude_code.tsresemblesclipinsrc/crew/triage.ts, which I did not change.
Left #17929 open: 8 unticked items remain (Every Talk conversation, every crew run's log and every review is a trace, kept forever. The raw bytes are the record, and a normalized view is rebuilt from them: thread → turns → steps (model call, tool call, subagent), each with times, model, account, tokens in, cached and out, cost, and outcome.; Import: POST a session file from an outside agent (Claude Code's session JSONL first, then Codex), so the owner's own sessions from his Mac and phone join the same archive, attributed and private by default.; One list of every trace, with facets: repository, app, file touched, tool, model or account, outcome, cost, date, person or agent. Saved searches. Full-text over titles and summaries, and over archived turns when asked.; …).
This pull is one small slice of #17929, not the whole issue. It reads a Claude Code session file as a trace and exports it as OTLP, from the terminal only. The issue is too big for one run, and the earlier parked attempt was declined for exactly that.
What changed
forge trace <session.jsonl>prints the tree: each turn's prompt, then one line per step (model reply or tool call), e.g.Edit a.ts +3 −1, with time, tokens in, cached and out, and outcome. A running total comes last.forge trace <session.jsonl> --otlpprints OTLP/JSON using the OpenTelemetry GenAI conventions (gen_ai.*). Ids are derived from the session, so exporting the same file twice gives the same document.src/trace/model.ts: the thread → turns → steps shape and the totals.src/trace/claude_code.ts: the reader.src/trace/otlp.ts: the export.src/cli/commands/trace.ts: the command.docs/features/traces.mdand aforge tracesection indocs/CLI.md.test/trace.test.tscovers parsing, totals, OTLP and the command.Checks
bun x tsc --noEmitpasses.test/trace.test.ts,cli-docs,cli-commands,dead-code*,doorless,feature-doors,feature-orphansandmcp-size.gate.tsis clean except one note,oneLineresemblingclipinsrc/crew/triage.ts. I did not merge them:clipis private to triage, and mine also strips control characters from untrusted input.No door:because this is terminal-only. The terminal side exists; the web, API and MCP sides are not built yet.Not done (left for follow-ups)
POSTimport into the archive, with attribution and private by default.Try it:
forge trace ~/.claude/projects/<app>/<session>.jsonl, add--otlpfor the OTLP form.🤖 Generated with Claude Code
Closes #17929