Skip to content

feat: add 'infer conversations show <id>' subcommand (#547) - #554

Merged
edenreich merged 2 commits into
mainfrom
feat/conversations-show-547
May 29, 2026
Merged

edenreich merged 2 commits into
mainfrom
feat/conversations-show-547

Conversation

@edenreich

@edenreich edenreich commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #547.

Adds a backend-agnostic infer conversations show <session-id> subcommand to inspect a saved conversation's entries chronologically. Until now infer conversations only had list, so inspecting a session (including hidden system_reminder entries) meant grepping raw .jsonl files — undiscoverable and jsonl-only.

Behavior

  • infer conversations show <session-id> prints entries chronologically with role, timestamp, content, and tool_call_id (for tool results).
  • Loads through storage.ConversationStorage.LoadConversation (same path as list), so it works on all backends: jsonl, sqlite, postgres, redis, memory — not by reading files directly.
  • --include-hidden (default off) surfaces entries persisted with Hidden: true: system reminders, plan-approval prompts, drained background-task results, and the synthetic verify message injected by infer agent.
  • --format text|json: text (default) is human-readable with per-entry headers (#n [role] timestamp [hidden] [tool_call_id=…] [model=…]); json emits one object per line (NDJSON) for jq, matching the infer agent stdout shape.
  • Session-id resolution mirrors infer agent --session-id via the rollover manager: literal UUIDs pass through, other values resolve a session group key (so you can show by group name, e.g. channel-telegram-12345).

Implementation

  • Filtering/formatting live in pure helpers (filterConversationEntries, buildConversationShowText, buildConversationShowJSON) with thin print wrappers — mirroring the existing renderConversationsTable build-then-print split, which keeps the handler small and the logic unit-testable.
  • Reuses formatting.ExtractTextFromContent for content (handles multimodal/image-only) and SessionRolloverManager.ResolveSessionID for id resolution. No new domain interfaces → no mock regen.

Acceptance criteria

  • show <session-id> prints entries chronologically (role, timestamp, content, tool_call_id).
  • Works against every storage backend via the storage layer, not files.
  • --include-hidden controls Hidden: true emission (default off).
  • --format json is one JSON object per line; --format text (default) is human-readable.
  • Registered in cmd/conversations.go alongside conversationsListCmd.
  • Session-id resolution mirrors infer agent --session-id (UUID passthrough + group-key lookup).
  • Tests cover hidden-vs-shown filtering and the json/text split.

Testing

  • task build, full go test ./..., and task lint (0 issues) pass; 9 new unit tests added.
  • End-to-end against the jsonl backend (seeded a 4-entry conversation incl. a hidden reminder): text omits hidden (3 shown) / --include-hidden shows 4 with [hidden]; --format json is valid NDJSON parsed by jq; not-found returns failed to load conversation: conversation not found: <id>.

Notes

  • Resolving a non-UUID id that doesn't exist yet registers a new (empty) session group — inherited directly from the ResolveSessionID path infer agent uses (intentional parity, not a divergent read-only variant).
  • Docs updated in-repo (README.md, docs/commands-reference.md). A matching [DOCS] follow-up will be filed against inference-gateway/docs.

Add a backend-agnostic `conversations show <session-id>` command to inspect a
saved conversation's entries chronologically (role, timestamp, content, and
tool_call_id for tool results). Entries load through the storage layer so it
works on jsonl/sqlite/postgres/redis/memory, not just by reading jsonl files.

- `--include-hidden` surfaces internally-injected entries (system reminders,
  plan-approval prompts, drained background-task results, the verify message)
  that are persisted with Hidden: true; off by default.
- `--format text|json`: text is the human-readable default; json emits one
  object per line (NDJSON) for jq, matching the `infer agent` stdout shape.
- Session id resolution mirrors `infer agent --session-id` via the rollover
  manager: literal UUIDs pass through, other values resolve a session group key.

Filtering and formatting live in pure helpers (filterConversationEntries,
buildConversationShowText, buildConversationShowJSON) with unit tests covering
hidden-vs-shown filtering and the json/text split. Docs added to README and
docs/commands-reference.md.
@edenreich
edenreich requested a review from a team as a code owner May 29, 2026 16:28
claude Bot added a commit to inference-gateway/docs that referenced this pull request May 29, 2026
Update the Conversation Management section in cli.md to reflect the
real CLI surface today:

- Use the plural `infer conversations` command group instead of
  singular `conversation`.
- Document the `list` and `show` subcommands; drop references to
  non-existent `export` and `delete` subcommands (including the stale
  `infer conversation export` example in Cost Tracking).
- Document `infer conversations show <session-id>` with the
  `--include-hidden` and `--format text|json` flags.
- Document session-id resolution (UUID passthrough plus session group
  key lookup, mirroring `infer agent --session-id`).
- Add example commands matching the in-repo CLI docs.
- Update the command summary table to use the plural group.

Refs: inference-gateway/cli#547, inference-gateway/cli#554.
Closes #87.

Co-authored-by: Eden Reich <[email protected]>
edenreich added a commit to inference-gateway/docs that referenced this pull request May 29, 2026
Update the Conversation Management section in cli.md to reflect the
real CLI surface today:

- Use the plural `infer conversations` command group instead of
  singular `conversation`.
- Document the `list` and `show` subcommands; drop references to
  non-existent `export` and `delete` subcommands (including the stale
  `infer conversation export` example in Cost Tracking).
- Document `infer conversations show <session-id>` with the
  `--include-hidden` and `--format text|json` flags.
- Document session-id resolution (UUID passthrough plus session group
  key lookup, mirroring `infer agent --session-id`).
- Add example commands matching the in-repo CLI docs.
- Update the command summary table to use the plural group.

Refs: inference-gateway/cli#547, inference-gateway/cli#554.
Closes #87.

Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: Eden Reich <[email protected]>
@edenreich
edenreich force-pushed the feat/conversations-show-547 branch from a386086 to 9b49467 Compare May 29, 2026 18:33
@edenreich
edenreich merged commit 41e06d5 into main May 29, 2026
@edenreich
edenreich deleted the feat/conversations-show-547 branch May 29, 2026 18:42
inference-gateway-releaser Bot pushed a commit that referenced this pull request May 29, 2026
## [0.115.0](v0.114.0...v0.115.0) (2026-05-29)

### 🚀 Features

* add 'infer conversations show <id>' subcommand ([#547](#547)) ([#554](#554)) ([41e06d5](41e06d5)), closes [#n](https://github.com/inference-gateway/cli/issues/n)
* **agent:** emit session_stats summary on stream completion ([#553](#553)) ([892203b](892203b))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.115.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add 'infer conversations show <id>' subcommand

1 participant