You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Harness: keep session-start context in the history across CLI restarts #281
Part of #261. Follow-up to #270, which fixes the repeated appends but not this.
Problem
Context that should be computed once per session is computed once per CLI process. The desktop app restarts the CLI with --resume when the provider, model or effort changes, and when bypass mode is turned on or off (src/server/ws/handler.ts). In the new process the memoized git status, instruction files and date are empty and are read again (src/context.ts).
Git status sits at the end of the system prompt (src/utils/api.ts), and instruction files and the date sit in the first user message. After the model has changed files, git status --short is different, so the first request after a restart misses the provider's prefix cache from the end of the system prompt onward, the whole history included. The text also still calls it "the git status at the start of the conversation".
Scenario: 30 turns into a session the user raises effort from medium to high. The CLI restarts, the git snapshot has changed, and the next request is billed at full price on DeepSeek, Kimi and other providers that cache by prefix.
Details, with how Codex CLI and ZCode keep this context in the history and append only changes: T-CTX-06.
Direction
Write git status and instruction files into the history as attachments: once when the session starts, recognized from the history on resume instead of recomputed, and appended as a change when they differ.
Stop rebuilding them into the system prompt and first user message on every request.
This changes the layout of every request, so measure cache hits before and after on the same session.
Separately worth checking: whether effort changes need a restart at all, or can go through a control request.
Activity