ADR 0015 · Context preservation + path conventions (~/dev fix)
- Status: accepted
- Date: 2026-05-23
Context
Real-use testing surfaced four issues bundled into one fix:
- The TUI's ephemeral REPL (no
--session) silently dropped every turn'sfinal_messages, so each new prompt only saw the system prompt + the latest user message. Models had no memory of prior turns in the same REPL session. WorkspaceRoot::resolvedidn't expand~. When models invokedBashwithcwd: "~/dev"orRead({"path":"~/notes.md"})the path resolution failed with "No such file or directory." The model misinterpreted the error as "directory doesn't exist."- The TUI's tool-call input summary truncated the partial-JSON stream at 80 chars, sometimes hiding closing braces and making patterns look different than they were.
- The default system prompt didn't tell the model that
~is supported in tool paths.
Decision
- Add
messages: Vec<Message>to the TUI'sApp. Initialize from session if any, else empty. Update fromRunEnd'sfinal_messageseach turn./clearwipes both the in-memory history and the session's persisted messages. WorkspaceRoot::resolveexpands a leading~or~/todirs::home_dir(). Affects all path arguments to all tools. TheBashcommand string is unchanged — the shell handles~expansion there.- At
ToolCallEnd, parse the accumulated input as JSON and renderkey="value", key=valuepairs. Fall back to raw truncation on parse failure. - Add a path-conventions bullet to the default system prompt.
Consequences
- Positive: Ephemeral REPL now feels like a real conversation
rather than a series of disconnected one-shots.
~/foopaths work transparently. Tool-call summaries are readable. The system prompt's conventions are accurate. - Negative:
App::messagesandsession.messagesare now two copies in--sessionmode (kept in sync atRunEnd)./clearis destructive to session-stored messages — documented. - Revisit if: The double-keeping causes correctness bugs (e.g.,
divergence after a mid-flight panic). The cleanest long-term
refactor would be to make
Apphold anArc<RwLock<Session>>and treat session as the single source of truth, with the ephemeral case using a synthetic in-memory session.