Skip to main content

openclaw-session-grep

openclaw-session-grep is a small CLI for quickly searching local OpenClaw session and transcript files. It is meant for finding prior conversations, tool usage, errors, expensive model runs, channel-specific history, and session labels without manually opening JSONL files.

It stays deliberately narrow: fast transcript search with useful filters, not an analytics database.

Install

pipx install openclaw-session-grep

For local development:

python -m venv .venv
. .venv/bin/activate
python -m pip install -e ".[dev]"

Where It Searches

By default, the CLI searches these locations if they exist:

  • $OPENCLAW_SESSION_DIR
  • $OPENCLAW_TRANSCRIPT_DIR
  • ~/.openclaw/sessions
  • ~/.openclaw/transcripts
  • ~/.openclaw

OPENCLAW_SESSION_DIR and OPENCLAW_TRANSCRIPT_DIR may contain multiple paths separated with your platform path separator. You can also pass --path one or more times to search specific files or directories.

Candidate files currently use these extensions: .jsonl, .json, .log, and .ndjson.

Examples

openclaw-session-grep "morning briefing"
openclaw-session-grep "timeout" --channel telegram --last 7d
openclaw-session-grep "message tool" --agent main --json
openclaw-session-grep "network\\s+timeout" --regex --tool-only
openclaw-session-grep --tool shell --summary
openclaw-session-grep "briefing" --context 2 --open

Filters

  • --agent main
  • --channel telegram
  • --last 7d, --last 24h, --since 2026-04-10T00:00:00Z, --until ...
  • --model gpt-5.4
  • --tool message
  • --session alpha
  • --type assistant|user|tool|system
  • --tool-only

Search is case-insensitive by default. Use --case-sensitive to change that, and --regex to treat the query as a Python regular expression.

Output Modes

Default terminal output includes timestamp, session, agent, channel, optional tool name, and a short excerpt.

Other modes:

openclaw-session-grep "timeout" --json
openclaw-session-grep "timeout" --markdown
openclaw-session-grep "timeout" --count-only
openclaw-session-grep "timeout" --summary

Use --usage to include usage/cost fields when present in the transcript record. Use --open to include path:line references.

Transcript Format

OpenClaw transcript schemas may vary, so the parser is intentionally tolerant. It reads newline-delimited JSON and extracts common fields such as:

  • timestamp: timestamp, time, created_at, createdAt, ts
  • session: session_key, sessionKey, session, label, conversation_id
  • agent: agent, agent_id, agentId, role
  • channel: channel, source, transport
  • message type: type, kind, role
  • model: model, model_name, modelName
  • tool: tool, tool_name, toolName, tool.name, function.name, first tool_calls[]
  • usage/cost: usage, cost, token_usage, tokenUsage

Malformed JSON lines are treated as plain text records so older logs can still be searched.

Performance Notes

The utility streams candidate files by path, then loads one transcript file at a time to support context records around each hit. That keeps memory bounded by the largest single transcript file rather than the whole transcript directory.

For large stores, pass a narrower --path, combine structured filters, or use --limit when you only need the first few hits.

Known Limitations

  • There is no persistent index; every invocation scans files.
  • Date filters skip records without timestamps instead of rejecting them.
  • Tool and structured filters are exact matches.
  • JSON object files that are not line-delimited are not recursively unpacked as full transcript arrays yet.

Development

python -m pip install -e ".[dev]"
python -m unittest discover -s tests

Sample fixtures live in tests/fixtures.

Releases

Tagged releases use GitHub Actions:

  • v* tags build and publish distributions to PyPI using the PYPI_API_TOKEN repository secret.
  • The Homebrew workflow updates pfrederiksen/homebrew-tap with a formula that installs from the PyPI source distribution.

Do not commit PyPI tokens. Store PyPI credentials as GitHub Actions secrets, or adapt the workflow to PyPI trusted publishing after configuring the publisher on PyPI.

Metadata

Release files for openclaw-session-grep 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openclaw-session-grep 0.1.2
File Size Uploaded
openclaw_session_grep-0.1.2.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openclaw-session-grep 0.1.2
File Interpreter ABI Platform
openclaw_session_grep-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 22.3 kB

Release files / openclaw_session_grep-0.1.2.tar.gz

Download URL openclaw_session_grep-0.1.2.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1f69538cbe716c13d1456c41574b2b883b69d2f68bb5004b8594fd5249cebc38
BLAKE2b-256 checksum
How to use checksums
732d3624826a3cdb17e1c4ffba02ece5867a906299fb2d349c9729235a4e4071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / openclaw_session_grep-0.1.2-py3-none-any.whl

Download URL openclaw_session_grep-0.1.2-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aed9bed62f3e2d4a716e49b99ad43d5c2ba0ea993e313f9691a5e256ab6754f0
BLAKE2b-256 checksum
How to use checksums
c9218ac5e01309e86b4357318bf4a6f764fe4cef2b2c5f7751a179b827c33b2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page