Start free
Guide Memory

How to give Qwen Code better memory

Updated 4 min read

The short answer

On its configuration page, Qwen Code's continuity features are chat history saved to disk, a welcome-back dialog, session recaps, and backups under ~/.qwen/file-history/ (Qwen Code settings docs). The same page mentions a Mem0 entry but does not describe how that integration works (Qwen Code settings docs). For memory that spans projects and tools, see persistent memory for AI agents and give your AI context.

On this page8 sections
  1. What Qwen Code keeps between sessions
  2. Welcome back, summaries and recaps
  3. How long session data lasts
  4. Settings files that control this behavior
  5. Mem0 on the configuration page
  6. What the configuration page does not cover
  7. Going further than one session
  8. Questions people ask

What Qwen Code keeps between sessions

Qwen Code saves chat history to disk through the general.chatRecording setting, and disabling it also prevents --continue and --resume from working (Qwen Code settings docs).

When you return to a project that has conversation history, Qwen Code can show a welcome-back dialog (Qwen Code settings docs).

Welcome back, summaries and recaps

Qwen Code detects when you return to a project with a previously generated project summary and shows a dialog that lets you continue your previous conversation or start fresh (Qwen Code settings docs). If you choose Start new chat session, that choice is remembered for the current project until the project summary changes (Qwen Code settings docs). The feature integrates with the /summary command and the quit confirmation dialog (Qwen Code settings docs).

The general.showSessionRecap setting can auto-show a one-line where you left off recap when you return to the terminal after being away (Qwen Code settings docs). It is off by default, and /recap triggers the recap manually regardless of the setting (Qwen Code settings docs).

How long session data lasts

Session backups live under ~/.qwen/file-history/ (Qwen Code settings docs). Data older than the retention setting is removed by a background pass that runs at most once per day (Qwen Code settings docs).

Two settings cap what a session keeps. model.maxSessionTurns limits how many user, model and tool turns are kept in a session, and -1 means unlimited (Qwen Code settings docs). model.sessionTokenLimit sets the maximum recorded prompt token count allowed before sending the next message; when it is exceeded, the next send is dropped and the session is not aborted (Qwen Code settings docs).

Settings files that control this behavior

Qwen Code uses JSON settings files for persistent configuration, stored in four locations, and can also be configured with environment variables and command-line arguments (Qwen Code settings docs). Settings apply in a defined order of precedence, where lower levels are overridden by higher ones (Qwen Code settings docs).

Project settings live in .qwen/settings.json in the project root, apply only when running Qwen Code from that project, and override user settings (Qwen Code settings docs). System settings apply to all Qwen Code sessions on the machine, for all users, and override user and project settings (Qwen Code settings docs). A project's .qwen directory can also hold other project-specific files related to Qwen Code's operation (Qwen Code settings docs).

Two conveniences matter when you edit these files. Environment variable references inside settings.json strings are resolved automatically when the settings load (Qwen Code settings docs). Legacy configuration is migrated to the new format automatically, and old settings files are backed up before migration (Qwen Code settings docs).

Mem0 on the configuration page

The Qwen Code configuration page mentions a Mem0 entry (Qwen Code settings docs). The page does not describe how that integration works, so check Qwen Code's own documentation for that entry before relying on it. No further detail is given here.

What the configuration page does not cover

The configuration page does not describe Qwen Code's dedicated Memory feature or its Rules feature, including any rules or context files and their precedence (Qwen Code settings docs). It also does not cover how MCP servers are configured (Qwen Code settings docs).

The page does not say what memory or rules content is injected into context, or any token or size limits on it (Qwen Code settings docs). It also does not say where cross-session data is stored beyond the ~/.qwen/file-history/ backups (Qwen Code settings docs).

Going further than one session

Each feature above works at the level of a session or a project (Qwen Code settings docs). If you want saved material available across projects and tools, see persistent memory for AI agents, give your AI context and connect any AI to your notes.

Questions people ask

Does Qwen Code remember previous sessions?

Yes, at the level of saved chat history. Chat history is saved to disk by the general.chatRecording setting, and a welcome-back dialog can let you continue your previous conversation or start fresh (Qwen Code settings docs). Disabling chat recording also prevents --continue and --resume from working (Qwen Code settings docs).

How do I see a recap of my last Qwen Code session?

Run /recap, which triggers the session recap manually regardless of any setting (Qwen Code settings docs). The general.showSessionRecap setting can also auto-show a one-line recap when you return to the terminal after being away, and it is off by default (Qwen Code settings docs).

Where does Qwen Code keep session backups?

Under ~/.qwen/file-history/ (Qwen Code settings docs). Data older than the retention setting is removed by a background pass that runs at most once per day (Qwen Code settings docs).

Can Qwen Code use KnowMan for memory?

This page cannot confirm that. The Qwen Code configuration page does not describe how to configure MCP servers, so this page gives no setup steps for adding a memory server (Qwen Code settings docs). For general background, see persistent memory for AI agents.

Carry context across sessions

Try KnowMan Pro for 14 days with no credit card. Create your account

Start free

Every new account starts with 14 days of Pro. No credit card.