Skip to content

feat(core): system prompt — pinned per session, replayed on resume (B2) - #43

Merged
ajianaz merged 1 commit into
developfrom
feat/b2-system-prompt
Aug 27, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/b2-system-prompt

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What

Storage (tole-core): the session header line gains an optional systemPrompt field — serde default + 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. The Storage trait exposes system_prompt() (default None).

Host (tole-cli): resolution order --system flag > TOLE_SYSTEM_PROMPT env > none.

  • tole run --system and tole chat --system: fresh sessions pin the resolved prompt into 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. 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

  • New test system_prompt_roundtrip_and_backward_compat: create → header holds prompt → reopen replays it; a hand-written pre-B2 header (no field) opens with system_prompt() == None. 123/123 tests, clippy clean.
  • Live validation (real provider): (1) pirate persona via chat --system applied — "Arrr, I be Tole, yer trusty first mate…"; (2) systemPrompt visible in the JSONL header line; (3) resumed process without the flag stayed in character — "Fair winds and followin' seas, matey — arrr!" (header-sourced).

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).
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 33b87da into develop Aug 27, 2026
11 checks passed
@ajianaz
ajianaz deleted the feat/b2-system-prompt branch August 27, 2026 14:56
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.

1 participant