Skip to content

feat(cli): tole chat — durable multi-turn REPL (B1 keystone) - #42

Merged
ajianaz merged 2 commits into
developfrom
feat/b1-chat-mode
Aug 27, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/b1-chat-mode

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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_turn now accepts pc Idle | Final as turn boundaries; mid-flight states are still refused (resolve via resume first).

Host (tole-cli): tole chat — one durable session, many turns:

  • REPL loop (you> prompt), each line becomes a full agentic turn with the existing durability (write-once JSONL, effect sandwich, approval gates inline)
  • State-aware dispatch: boundary → run_turn; any mid-flight state (denial / provider failure / loop guard / budget exhausted) is resolved via resume_turn on the next message — a failed turn never wedges the conversation
  • /exit, /quit, /status commands; 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

  • New core test 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.
  • 123/123 tests pass, clippy clean.
  • Live validation (real provider): (1) 3-turn chat — codeword memorized in turn 1, recalled in turn 2 (PINEAPPLE77), read_file tool 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) --last picked the newest session (entries 10 → 14).

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}"),
@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

🔍 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
ajianaz merged commit a5727de into develop Aug 27, 2026
11 checks passed
@ajianaz
ajianaz deleted the feat/b1-chat-mode branch August 27, 2026 14:23
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants