Skip to content

[FEATURE] Add /traces shortcut and infer traces command (local span-tree viewer) #903

Description

@edenreich

Summary

PR #901 (towards #893) records the traces signal locally: every session writes a per-session
~/.infer/telemetry/<session>-traces.jsonl with a session root span, chat <model> spans per
LLM turn, and execute_tool <name> spans per tool call. Nothing in the CLI renders them yet -
the only consumer today is an OTLP collector, which most users don't run.

Add a local span-tree viewer, paired the same way infer stats / /stats are:

  • infer traces [session-id] - render the span tree of a session (default: the most recent one)
    from the local trace file, with durations, so per-run latency questions ("what took 27s in that
    run?") are answerable without any collector:
session (standard, success)                    42.1s
|-- chat deepseek/deepseek-v4-flash             3.2s
|-- execute_tool Read                           9ms
|-- chat deepseek/deepseek-v4-flash             2.8s
`-- execute_tool Bash                          27.5s
  • /traces [session-id] - the same view as a chat shortcut (markdown output), matching the
    internal/shortcuts/stats.go pattern.

This is read-only over the existing -traces.jsonl format (one stdouttrace span stub JSON object
per line, already parsed by internal/telemetry/tracer_test.go::readSpans). Once subprocess span
ingestion lands (#904), child-process spans appear in this view automatically as children of
their tool span - no viewer changes needed.

Acceptance Criteria

  • infer traces [session-id] renders the span tree (root -> LLM turns -> tool calls) with per-span durations from the local per-session trace file; with no argument it picks the most recent session.
  • infer traces --list (or equivalent) enumerates sessions that have trace files, so a session id can be found without ls-ing the telemetry dir.
  • /traces [session-id] chat shortcut renders the same tree as markdown, mirroring the stats command/shortcut pairing.
  • --format json emits the tree as structured output.
  • Spans with error status / error.type are visibly marked.
  • Works fully offline from local files; no OTLP endpoint required; no prompt/response content displayed beyond existing span names/attributes.

Activity

  1. added
    enhancement
    on Jul 13, 2026
  2. moved this to Todo in 2026on Jul 13, 2026
  3. moved this from Todo to In progress in 2026on Jul 13, 2026
  4. moved this from In progress to QA in 2026on Jul 13, 2026
  5. added a commit that references this issue on Jul 13, 2026
    8000a4b
  6. moved this from QA to Done in 2026on Jul 13, 2026
  7. inference-gateway-releaser commented on Jul 16, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.147.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementreleased

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions