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 #17968

opened this in answer to

Merged 12h 17m ago, live in production

forge trace now reads Codex rollout files as well as Claude Code sessions. This closes only the "Codex" half of the Import item in #17929. Everything else on that issue is still open, and I did not try to fit it into one run.

Notes

opened this

forge trace now reads Codex rollout files as well as Claude Code sessions. This closes only the "Codex" half of the Import item in #17929. Everything else on that issue is still open, and I did not try to fit it into one run.

What changed

  • src/trace/codex.ts reads a rollout (session_meta, turn_context, response_item, event_msg) into the existing turns-and-steps shape.
    • Codex's startup environment messages are not counted as prompts.
    • A reply takes the token count that follows it.
    • A tool call's outcome comes from the exit_code in its output.
    • Lines that aren't records are counted as skipped, and an oversize line is skipped.
  • src/trace/session.ts picks the reader from the first record. forge trace <file> and --otlp both go through it.
  • The trace source is now "claude-code" | "codex". The OTLP export names the agent and the provider (openai for Codex, anthropic for Claude Code) from it.
  • docs/features/traces.md and docs/CLI.md describe the new input.

Checks

  • test/trace.test.ts has new tests covering format detection, prompts, tool outcomes, token attribution and the OTLP provider.
  • The trace tests (6) pass.
  • tsc --noEmit is clean.
  • The CLI-docs, feature-doors, front-matter, dead-code and unused-exports tests I ran pass.
  • The gate's duplicate-function note about turnAt in codex.ts and claude_code.ts is still there. It is a note and does not fail the check.

Not done

  • Storing an import: there is still no POST, no archive and no database.
  • The list with facets, the trace page with its time strip, what a run changed, compare, permalinks and share links.
  • Cost: neither format records one.
  • The terminal is the only door, so there is no page, API route or src/tui/ screen to match. The change touches no web page, action or API route, so the both-doors rule does not apply.

Try it: forge trace ~/.codex/sessions/<day>/rollout-<id>.jsonl, then add --otlp.

🤖 Generated with Claude Code

Closes #17929

3 earlier comments · 1 event
commented

forge trace now reads Codex rollout files as well as Claude Code sessions. This closes only the "Codex" half of the Import item in #17929. Everything else on that issue is still open, and I did not try to fit it into one run.

What changed

  • src/trace/codex.ts reads a rollout (session_meta, turn_context, response_item, event_msg) into the existing turns-and-steps shape.
    • Codex's startup environment messages are not counted as prompts.
    • A reply takes the token count that follows it.
    • A tool call's outcome comes from the exit_code in its output.
    • Lines that aren't records are counted as skipped, and an oversize line is skipped.
  • src/trace/session.ts picks the reader from the first record. forge trace <file> and --otlp both go through it.
  • The trace source is now "claude-code" | "codex". The OTLP export names the agent and the provider (openai for Codex, anthropic for Claude Code) from it.
  • docs/features/traces.md and docs/CLI.md describe the new input.

Checks

  • test/trace.test.ts has new tests covering format detection, prompts, tool outcomes, token attribution and the OTLP provider.
  • The trace tests (6) pass.
  • tsc --noEmit is clean.
  • The CLI-docs, feature-doors, front-matter, dead-code and unused-exports tests I ran pass.
  • The gate's duplicate-function note about turnAt in codex.ts and claude_code.ts is still there. It is a note and does not fail the check.

Not done

  • Storing an import: there is still no POST, no archive and no database.
  • The list with facets, the trace page with its time strip, what a run changed, compare, permalinks and share links.
  • Cost: neither format records one.
  • The terminal is the only door, so there is no page, API route or src/tui/ screen to match. The change touches no web page, action or API route, so the both-doors rule does not apply.

Try it: forge trace ~/.codex/sessions/<day>/rollout-<id>.jsonl, then add --otlp.

🤖 Generated with Claude Code

the crew's run was interrupted: provider limit, resumes 22:08 UTC — every subscription this repository may use is resting (API Error: 402 This request requires more credits, or fewer max_tokens. You requested up to 128000 tokens, but can only afford 4000. To increase, visit https://)
commented

The Codex reader from my earlier push is the only change on this branch. The split into #17991–#17995 leaves nothing more for this issue, so I made no new commits.

What the branch holds

  • forge trace <file> reads a Codex rollout as well as a Claude Code session, with the format sniffed from the first record (src/trace/codex.ts, src/trace/session.ts).
  • The OTLP export names the provider from the source.
  • The change is terminal-only and touches no page, action or API route, so the both-doors rule does not apply. It adds no module-level state, and the dead-code and unused-exports tests pass.
  • test/trace.test.ts covers the Codex reader and the OTLP provider.

For the children

  • #17994 (import a Claude Code session) can reuse parseSession from src/trace/session.ts for the Codex half. It needs no new reader.
  • The Step and Trace types in src/trace/model.ts are the shape #17991 can build the stored record on.
  • The forge's own conversations and runs have no reader yet, so #17991 needs one.

This issue stays open as the parent until those land.

🤖 Generated with Claude Code

commented

I merged main into this branch and pushed it. The only conflict was docs/features/traces.md.

In that file I kept main's new "One run as a tree (#17993)" section whole. I kept this pull's Codex reader in the modules line (src/trace/codex.ts and src/trace/session.ts). I removed "Codex files" from the "Not yet" list, since the reader now exists. I also moved "tokens and cost per step" into that list from main's version.

bun x tsc --noEmit printed nothing. The two trace test files pass (17 tests). I did not run the full suite; the forge runs it on the push.

commented

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.; …).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs