OptChat is Victor Taelin's design for an AI chat that never ends and never forgets. Credit for the design and the spec goes to Victor Taelin; this recipe only adds storage. Read the spec for the details. In short:
- There is one chat. Every message, yours and the agent's, including tool calls and results, is appended word for word to a log that is never edited.
- A background compactor turns each message into a one-line summary, then merges pairs of lines into coarser lines, building a binary tree over the whole history.
- Each turn starts fresh. The agent sees a fixed-size view of the whole chat, recent messages in detail and older ones more coarsely, then your message.
- When a line is too vague, the agent zooms into it, down to the original message.
The spec stores the log and the tree as daily JSONL files and says to persist the folder after every turn and back it up, because the log is your history. Here the chat folder is a Wiele checkout, and every change to the log or the tree uploads within seconds, with each version kept.
Setup
OptChat has one writer, so it gets its own copy with live uploads on. Live uploads never write to main, which is why the chat lives on a copy.
wiele workspace create "OptChat" --slug optchat
wiele copy create chat-log --workspace optchat
mkdir -p ~/optchat/chat
wiele track optchat:/ ~/optchat --copy chat-log
printf 'chat/lock\n' > ~/optchat/.wieleignore
wiele live enable --directory ~/optchat
wiele daemon install
chat/lock is the socket OptChat holds while it runs; it has no place in the upload. daemon install keeps the uploads going after a restart. Run all of this on the always-on machine where OptChat runs.
The log only grows, and Wiele keeps every version of every file, so each upload of today's log stores a new full copy. Keep past versions for a week and drop older ones:
wiele workspace retention set --workspace optchat --keep-days 7
A finished day's file then keeps only its last version once the week is over. Rules that keep less take effect after 7 days; see Retention.
Folder layout
optchat:/ (copy chat-log)
.wieleignore stays local
chat/
main/
2026-10-06.jsonl the log: one message per line, appended, never edited
2026-10-07.jsonl
tree/
2026-10-06.jsonl summary nodes, appended as the compactor builds them
2026-10-07.jsonl
lock OptChat's lock socket, ignored
The prompt
Paste this into Claude Code or Codex on the machine that runs OptChat, after the setup above:
Build OptChat for me, following the spec at
https://gist.github.com/VictorTaelin/91837951a5ce5b38f341ec1ba1df6449
Read the whole spec first and follow it exactly, including its checklist of mistakes.
Storage:
- Put the code in ~/src/optchat. Put the chat directory at ~/optchat/chat, with main/ and tree/
as the spec describes, and the lock socket at ~/optchat/chat/lock.
- ~/optchat is a Wiele checkout of optchat:/ on the copy chat-log, with live uploads on.
Wiele uploads every change to the log and tree files a few seconds after the file stops
changing. Do not use git in ~/optchat and do not add your own backup step.
- Never delete, rename or rewrite files in ~/optchat/chat. Live uploads publish deletions too.
When it runs, check the uploads:
- `wiele live status --directory ~/optchat` must show live as on.
- After the first message, `wiele daemon logs` must show an upload, and
`wiele ls optchat:/chat/main --copy chat-log` must list today's log file.
Report the revision SHA of the first upload.
Working with OptChat
Once it runs, you talk to OptChat itself. A few requests that touch Wiele, which it answers with its shell tools:
"Is the log backed up?"
wiele live status --directory ~/optchat
wiele daemon logs
"Show me the log as it was yesterday morning."
wiele stat optchat:/chat/main/2026-10-06.jsonl --copy chat-log
wiele history RESOURCE_ID --workspace optchat --copy chat-log
wiele read optchat:/chat/main/2026-10-06.jsonl --copy chat-log --revision SHA
"I want to read the chat on my laptop too."
On the laptop, fetch a second checkout and keep it in sync. Use it for reading. Only the machine that runs OptChat writes the chat.
wiele fetch optchat:/chat ~/optchat-read --copy chat-log
wiele sync enable --directory ~/optchat-read
If uploads stop
Live turns off when it hits an error it can't retry, such as an expired session or a payment problem, and logs the code. OptChat keeps running and writing locally, so nothing is lost; the files upload once you fix the cause and run wiele live enable --directory ~/optchat again. Check wiele daemon logs after a reboot or a long pause. See Background sync.