Repository navigation
feat(core): system prompt — pinned per session, replayed on resume (B2) - #43
Merged
Merged
Conversation
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).
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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
Storage (tole-core): the session header line gains an optional
systemPromptfield — serdedefault+skip_serializing_if, so pre-B2 files replay unchanged (backward-compat test included).create_with()pins the prompt at creation;open()re-loads it from the header;compact()carries it through rewrites. TheStoragetrait exposessystem_prompt()(defaultNone).Host (tole-cli): resolution order
--systemflag >TOLE_SYSTEM_PROMPTenv > none.tole run --systemandtole chat --system: fresh sessions pin the resolved prompt into the header.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. Persona survives process restarts by construction.Why
B2 gives tole a stable identity per session — the foundation for the v1.1 personal-assistant direction. Header persistence (not per-turn) means the prompt is part of the durable replay recipe: one line in the file, applied to every provider request, no drift.
Testing
system_prompt_roundtrip_and_backward_compat: create → header holds prompt → reopen replays it; a hand-written pre-B2 header (no field) opens withsystem_prompt() == None. 123/123 tests, clippy clean.chat --systemapplied — "Arrr, I be Tole, yer trusty first mate…"; (2)systemPromptvisible in the JSONL header line; (3) resumed process without the flag stayed in character — "Fair winds and followin' seas, matey — arrr!" (header-sourced).