fix(tui): persist one-shot session trails for post-mortem debugging - #138
Merged
Conversation
run_once used new_session_with_provider, which opens an in-memory-only trail log (persist.open_ephemeral) discarded the moment the process exits. A one-shot run that stops without producing anything -- hits its step budget, say -- left no record of what it actually did. Reproduced live today: a real build task burned its whole 50-step budget on bash exploration with nothing to inspect afterward, not even which commands it ran. Switches to new_session_persistent_with_provider (already used by graph pipelines), which writes to .lex/sessions/<id>.db instead. Not a straight swap, though: new_session_from_log always starts a session's in-memory cache at messages: [], regardless of what a log under that id already holds -- correct for a pipeline node's id, which is reused deliberately across runs of the SAME pipeline, but wrong for a fixed "cli" id reused across SEPARATE one-shot invocations. A second `bin/lex-code "task"` in the same project would find "cli"'s log already holding the first run's events, immediately fail the fresh session's event_count check (#136), and refuse before ever reaching the model. cli_session_id() generates a fresh id per invocation instead (timestamp + random suffix), so each run gets its own file with no collision. The one-shot output now names the trail file so a stuck or incomplete run can actually be inspected afterward (confirmed live: sqlite3 against the file shows the full conversation, including tool calls and the model's own reasoning text). repl is untouched -- a live REPL user already watches every step as it happens, which is the case the ephemeral log was originally fine for. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
🤖 Generated with Claude Code