Repository navigation
feat(cli): tole chat — durable multi-turn REPL (B1 keystone) - #42
Merged
Merged
Conversation
Core: state machine gains the (Final, Planning) re-open transition — a delivered answer re-opens when the next user message arrives; the tree stays append-only. run_turn now accepts pc Idle|Final as turn boundaries (mid-flight states still refused — resolve via resume). Host: 'tole chat' — one durable session, many turns. REPL loop with state-aware dispatch: boundary starts a new turn; any mid-flight state (denial / provider failure / loop guard / budget) is resolved via resume_turn on the next message, so a failed turn never wedges the conversation. /exit /quit /status commands; --resume <id> and --last (most recently modified session); Ctrl-D/EOF clean exit — every commit was already durable, so a killed chat resumes losslessly. Live validation (real provider): 3-turn chat with mid-conversation read_file tool call; cross-process --resume recalled context from the prior process (codeword test); --last picked the newest session (entries 10 -> 14). 123/123 tests, clippy clean.
| }; | ||
|
|
||
| match outcome { | ||
| Ok(TurnOutcome::Final { text }) => println!("tole> {text}"), |
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
CodeCora caught a real UX bug on PR #42: when resume_turn surfaced a non-Final outcome (re-denial, provider still down), the freshly typed message was silently discarded. Now the dispatch loop keeps resolving (bounded: 2 retries per message) until the session lands on a turn boundary, and only then runs the user's message — input is never dropped, and a wedged session surfaces its state instead of spinning.
ajianaz
added a commit
that referenced
this pull request
Aug 27, 2026
…2) (#43) Storage: header line gains an optional systemPrompt field (serde default + skip-if-absent, so pre-B2 files replay unchanged — verified by test). create_with pins it at creation; open() re-loads it; compact() carries it through rewrites. Storage trait exposes system_prompt(). Host: --system flag on run and chat (highest priority) > TOLE_SYSTEM_PROMPT env > none. Fresh sessions pin the resolved value in the header; resume paths (tole resume, tole chat --resume/--last) re-apply exactly the header-pinned prompt — never the ambient env, which may have changed since the session was created. Live validation (real provider): pirate persona via --system applied and held; systemPrompt present in the JSONL header; a resumed process without the flag stayed in character (header-sourced). Also: corrects the mid-flight comment from PR #42 (the exhausted-retries path surfaces status but does not auto-queue the typed message — the user retypes; comment now says exactly that). Co-authored-by: ajianaz <[email protected]>
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.
What
Core (tole-core): the state machine gains the
(Final, Planning)re-open transition — a delivered Final answer re-opens when the next user message arrives (the tree stays append-only; a re-open is just another transition, never a rewrite).run_turnnow acceptspc Idle | Finalas turn boundaries; mid-flight states are still refused (resolve via resume first).Host (tole-cli):
tole chat— one durable session, many turns:you>prompt), each line becomes a full agentic turn with the existing durability (write-once JSONL, effect sandwich, approval gates inline)run_turn; any mid-flight state (denial / provider failure / loop guard / budget exhausted) is resolved viaresume_turnon the next message — a failed turn never wedges the conversation/exit,/quit,/statuscommands; clean Ctrl-D/EOF--resume <id>and--last(most recently modified session in the dir)Why
B1 is the keystone of the v1.1 chat-first replan (docs/epics.md): tole's identity is a durable conversational harness — without a chat loop it isn't a chatbot. This turns the proven one-shot turn engine into the product surface.
Testing
chat_reopens_final_session_for_next_turn: turn 1 → Final → turn 2 on the same session; tree holds 2 user + 2 assistant messages; mock provider.PINEAPPLE77),read_filetool call mid-conversation in turn 3, all in one session file (10 entries); (2) cross-process--resume— a fresh process recalled the codeword from the prior process's session; (3)--lastpicked the newest session (entries 10 → 14).