OAI Chat PersistencePersistent, multi-session AI chat for Ollama, local LLMs, and any VS Code-compatible model. Chat history survives restarts, sessions are stored as plain JSON files you own, and any VS Code-compatible model works — Ollama, GitHub Copilot, LM Studio, and more. 🚀 Why This Extension?✅ Persistent Sessions — Chats saved to 🔥 How It Compares
📝 FeaturesPersistent Sessions
Multi-Model SupportWorks with any extension that contributes language models via
Automatic Context Compaction
File Injection with
|
| Syntax | What it injects |
|---|---|
@src/panel.js |
Full file contents |
@src/ |
Directory listing |
@/home/user/.vscode/ |
Absolute directory listing |
@find:*.ts |
All .ts files in workspace |
@find:/path:*.json |
All .json files under any directory |
@search:myFunction |
All lines containing myFunction |
@search:/path:term |
Grep under any directory |
No tool calling required — works with every model.
System Prompts per Session
Set a persistent system prompt for each session. Survives context compaction.
Streaming with Cancellation
- Responses stream token-by-token with a stop button
- Partial responses are displayed; failed responses leave history intact
🛠️ Requirements
- VS Code 1.90+
- At least one extension that contributes language models:
- GitHub Copilot
- Ollama for VS Code
- Continue or similar
📦 Installation
Search for OAI Chat Persistence in the VS Code Extensions view, or:
ext install bhlevca.oai-chat-persistence
🎯 Usage
- Click the chat bubble icon in the Activity Bar (or press
Ctrl+Shift+O/Cmd+Shift+O) - Click + to create a new session and give it a name
- Select a model from the dropdown
- Start chatting — history is saved automatically
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+Shift+O / Cmd+Shift+O |
Open / focus chat panel |
Enter |
Send message |
Shift+Enter |
New line in message |
⚙️ Configuration
| Setting | Default | Description |
|---|---|---|
oaiChatPersistence.defaultModel |
"" |
Model ID to pre-select for new sessions |
oaiChatPersistence.contextWindowTokens |
6000 |
Token budget before auto-compaction triggers (~4 chars/token). Set to 0 to disable. |
oaiChatPersistence.compactionKeepMessages |
8 |
Number of most-recent messages kept verbatim after compaction |
💾 Session Storage
Sessions are stored as plain JSON files at:
~/.vscode/oai-chat-persistence/<session-name>.json
Back them up, version-control them, or copy them between machines.
🔄 Side-by-Side with Copilot Chat
If the OAI Chat panel conflicts with Copilot Chat in the Activity Bar, right-click the OAI Chat icon → Move to Secondary Side Bar to have both visible simultaneously.
🐛 Feedback & Issues
Found a bug or have a feature request? Open an issue on GitHub.
📜 License
MIT — see LICENSE
Features
Persistent sessions
Conversations are saved to ~/.vscode/oai-chat-persistence/<session-name>.json and reloaded automatically. Create as many sessions as you like, switch between them instantly, export any session as JSON.
Works with any VS Code language model
Uses the standard vscode.lm API — it sees the same models as GitHub Copilot Chat: local Ollama models, Copilot models, or any other extension that contributes language models.
Automatic context compaction
When a conversation grows beyond the configured token budget, the extension summarises the oldest messages using the model itself, replacing them with a compact card. The most recent N messages are always kept verbatim. Compaction only commits to disk after a successful response — a failed request never destroys history.
File injection with @ references
Attach any file, directory listing, or search result directly into your message:
| Syntax | What it injects |
|---|---|
@src/panel.js |
Full file contents |
@src/ |
Directory listing |
@/home/user/.vscode/ |
Absolute directory listing |
@find:*.ts |
All .ts files in workspace |
@find:/path:*.json |
All .json files under a path |
@search:myFunction |
All lines containing myFunction |
@search:/path:term |
Grep under any directory |
The model receives the actual content — no tool calling required, works with every model.
System prompts per session
Set a persistent system prompt for each session via the toolbar button. Survives compaction.
Streaming with cancellation
Responses stream token-by-token with a stop button. Partial responses are displayed; failed responses leave history intact.
Requirements
- VS Code 1.90+
- At least one extension that contributes language models:
- GitHub Copilot — GPT-4o, Claude, etc.
- Ollama for VS Code or similar — local models
Installation
Search for OAI Chat Persistence in the VS Code Extensions view, or:
ext install bhlevca.oai-chat-persistence
Usage
- Click the chat bubble icon in the Activity Bar (or press
Ctrl+Shift+O/Cmd+Shift+O) - Click + to create a new session and give it a name
- Select a model from the dropdown
- Start chatting — history is saved automatically
Keyboard shortcut
| Shortcut | Action |
|---|---|
Ctrl+Shift+O / Cmd+Shift+O |
Open / focus the chat panel |
Enter |
Send message |
Shift+Enter |
New line in message |
Configuration
| Setting | Default | Description |
|---|---|---|
oaiChatPersistence.defaultModel |
"" |
Model ID to pre-select for new sessions |
oaiChatPersistence.contextWindowTokens |
6000 |
Token budget before auto-compaction triggers (~4 chars/token). Set to 0 to disable. |
oaiChatPersistence.compactionKeepMessages |
8 |
Number of most-recent messages kept verbatim after compaction |
Session storage
Sessions are stored as plain JSON files at:
~/.vscode/oai-chat-persistence/<session-name>.json
You can back them up, version-control them, or copy them between machines.
Tip: Side-by-side with Copilot Chat
If the OAI Chat panel conflicts with Copilot Chat in the Activity Bar, right-click the OAI Chat icon → Move to Secondary Side Bar to have both visible simultaneously.
License
MIT — see LICENSE