You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support omp (oh-my-pi) sessions: history import and host detection #166
Problem. Running under omp (it loads Claude Code plugins and sets CLAUDE_PLUGIN_ROOT), the plugin reports host claude and te history import finds nothing: ClaudeCode.history() only reads ~/.claude/projects, while omp keeps sessions in ~/.omp/agent/sessions/<cwd-folder>/<timestamp>_<id>.jsonl.
The omp log is Pi-style (tree of id/parentId entries, toolCall/toolResult, same usage fields), with two differences:
the first line is {"type":"title",...}, so pi_session_header (which only checks entry 0) returns {};
extra entry types (custom, custom_message, developer, credential_pin, model_change, ...) that must be ignored.
Proposal.
trace/pi.py: make pi_session_header scan the first few entries for type == "session"; have pi_session_to_claude write timestamp and cwd on user lines (needed by claude_log_head / history import).
plugin/hosts.py: add Omp(Pi) with keeps_history = True and a history() that lists omp's session dir, converting each log with pi_session_to_claude into a cache under state_root() (keep the source mtime so the "recent"/"too_old" filters work). Register in HOSTS; add omp to --host.
Host detection: pick omp rather than claude when running under omp (needs a discriminator from omp's hook env; I haven't confirmed which var).
Tests: fixture omp log starting with a title line; assert history lists it and pi_prompt_count ignores non-message entries.
Verified locally with a minimal patch of 1 + a history() hook on ClaudeCode: te history import --dry-run went from nothing to "2 earlier session(s) would be read", and te status showed +2 from earlier history, 44 prompts. Happy to send a PR for 1, 2, 4 if the approach is acceptable; 3 needs maintainer input.
Correction after a closer look: omp does not run the plugin as Claude Code. It loads the Pi extension (plugin/pi/tokeneconomizer.ts), so live sessions are folded under host pi. Its shell sets OMPCODE=1 and PI_SESSION_ID, plus CLAUDECODE=1, and that last one is why te defaults to claude. So the fix belongs on the Pi host:
Pi.keeps_history = True, with Pi.history() listing ~/.pi/agent/sessions and ~/.omp/agent/sessions (files are named <timestamp>_<id>.jsonl, and the id comes after the last _).
A new Host.log_head(): the default is claude_log_head, and Pi reads pi_session_header. history.plan uses ctx.host.log_head and ctx.host.prompt_count, and replay_envelope reads ctx.host.mechanism_trace(...), so raw Pi logs get folded natively.
_still_eligible also accepts *_<sid>.jsonl.
pi_session_header scans past omp's leading title line.
default_host: OMPCODE=1 means pi, checked before CLAUDECODE.
I have this on a local branch with a fail-before/pass-after test (tests/test_pi_history.py). The full suite gives 829 passed, 24 skipped on Windows. 2 test_history_import tests fail with or without the patch because of Windows path length (WinError 206). Smoke on a real machine: the 3 omp sessions of a repo were imported under pi, and a real te_bootstrap.py hook --host pi SessionStart→PostToolUse→Stop→SessionEnd cycle folded a session with token usage. I can open a PR.
Thanks for the detailed write-up and for the follow-up correction. You're right that omp loads the Pi extension, so the fix belongs on the Pi host as you laid out in your comment, including the OMPCODE=1 check before CLAUDECODE in default_host.
Please go ahead and open the PR with that change and tests/test_pi_history.py. If you can, also include a short note on the omp sessions you checked it against (how many sessions, and what te history import --dry-run and te status showed). That makes it easier to review.
Activity
tejasach06 commentedon Nov 8, 2026
Correction after a closer look: omp does not run the plugin as Claude Code. It loads the Pi extension (
plugin/pi/tokeneconomizer.ts), so live sessions are folded under hostpi. Its shell setsOMPCODE=1andPI_SESSION_ID, plusCLAUDECODE=1, and that last one is whytedefaults toclaude. So the fix belongs on the Pi host:Pi.keeps_history = True, withPi.history()listing~/.pi/agent/sessionsand~/.omp/agent/sessions(files are named<timestamp>_<id>.jsonl, and the id comes after the last_).Host.log_head(): the default isclaude_log_head, and Pi readspi_session_header.history.planusesctx.host.log_headandctx.host.prompt_count, andreplay_envelopereadsctx.host.mechanism_trace(...), so raw Pi logs get folded natively._still_eligiblealso accepts*_<sid>.jsonl.pi_session_headerscans past omp's leadingtitleline.default_host:OMPCODE=1meanspi, checked beforeCLAUDECODE.I have this on a local branch with a fail-before/pass-after test (
tests/test_pi_history.py). The full suite gives 829 passed, 24 skipped on Windows. 2test_history_importtests fail with or without the patch because of Windows path length (WinError 206). Smoke on a real machine: the 3 omp sessions of a repo were imported underpi, and a realte_bootstrap.py hook --host piSessionStart→PostToolUse→Stop→SessionEnd cycle folded a session with token usage. I can open a PR.SakshamUboweja commentedon Nov 8, 2026
Thanks for the detailed write-up and for the follow-up correction. You're right that omp loads the Pi extension, so the fix belongs on the Pi host as you laid out in your comment, including the OMPCODE=1 check before CLAUDECODE in default_host.
Please go ahead and open the PR with that change and tests/test_pi_history.py. If you can, also include a short note on the omp sessions you checked it against (how many sessions, and what te history import --dry-run and te status showed). That makes it easier to review.