Project: Project AI Chatbot Memstore Version: qwen_memproxy.py 1.1.0, QwenMemProxy.sh 1.0.2 Date: 2026-10-26 Another collaboration between Andrew.human and Claude.ai
Written to be read by people and by AI models.
The llama-server web page ignores the system text the server offers it, so memory set at server start never reached the page. qwen_memproxy.py is a go-between that sits in front of a llama-server. It forwards every request unchanged (the web page, the API, streamed replies) except chat requests, to which it adds the operator-approved memstore entries as background facts. It never changes the memory store.
| Profile | Open this | Forwards to |
|---|---|---|
4b |
http://clone:8090/ |
Qwen3-4B server on 8080 |
05b |
http://clone:8091/ |
Qwen2.5-0.5B server on 8081 |
The Qwen servers and their ports are unchanged. Anything that talks to port 8080 or 8081 directly (such as qwen_memchat.py) works as before, without the go-between.
sh Qwen25_05B.sh (start the Qwen server first)
sh QwenMemProxy.sh 05b (start the go-between; open http://clone:8091/)
sh QwenMemProxy.sh stop 05b (ordered stop; do this before stopping the Qwen server)
QwenMemProxy.sh uses python3.8 for the go-between and python3.6 to read memstore (the Clone's python3.8 has no SQLite), and the database at $MEMSTORE_DB or else /root/memstore/memstore.db. Its log goes in /root/qwen_logs/memproxy_PROFILE_DATE.log and records start, stop and the entry count whenever it changes.
--place)| Setting | What it does | Default for |
|---|---|---|
user |
Puts the facts in front of the latest question only, as "Facts about me ... My question: ...". Earlier turns are untouched, and the page's own chat view shows only what you typed. | 05b |
system |
Adds the facts to the end of the system message. | 4b |
Why: a very small model (the 0.5B) gave little weight to system text and answered "Windows" despite the facts being present. Text next to the question is weighed more. For the 4B the system message is better because that part of the prompt is cached by the server, while facts in the question add about 100 tokens of reading (roughly 20 seconds at the 4B's speed) to every message. These defaults are untested guesses on real models; change with --place if the other works better.
--refresh), so a new approve or add applies to the next chat with no restart.--place system the facts go at the end of the system message, or in a new one if the page sent none. With --place user they go in front of the latest user message.POST /v1/chat/completions is changed. Everything else passes through byte for byte.chat request: memory added in front of the latest user message, ...to the page's system message, ...as a new system message, no memory to add ..., or not a normal chat body .... If the log shows no chat request line after you ask something, the page is not going through the go-between (check the port in the address bar).qwen_memproxy.py)| Option | Meaning |
|---|---|
--profile 4b|05b |
Ports as in the table. Default 4b. |
--listen-port N, --upstream-port N |
Override the profile. |
--host ADDR |
Address to listen on. Default 0.0.0.0. |
--memstore PATH, --python PATH, --db FILE, --limit N |
As for qwen_memchat.py. |
--place system|user |
Where the facts go (see above). |
--drop-tools WORDS |
The llama-server web page offers the model its own tools. A tool whose name or description contains one of these comma-separated words is removed before the request is forwarded. Default all for the 05b profile and runtime for the 4b profile. runtime removes the page's get_info tool ("Get runtime info (OS name)"; the page's other tool is get_datetime): it reports the browser PC's operating system, and the 0.5B answered "Windows" from it instead of using the memory. On the 0.5B even the harmless get_datetime made some answers wander or start writing a tool call, hence all there. none lets every tool through; all removes every tool. The log lists the tools the page offers (once per set) and what was dropped, so the real names can be checked. |
--refresh S |
Seconds between memory re-reads. Default 5. |
It prints qwen_memproxy 1.1.0 (2026-10-26) once at start, to its log.
qwen_memchat.py when you want transcripts for the proposer.0 stopped normally, 2 the port could not be opened (often because one is already running).
sh QwenMemProxy.sh stop 05b (or 4b) asks the program to stop itself and finish cleanly. Stop the go-between first, then the Qwen server in your usual way.
remember:)Start a message with remember: and the text after it is saved to the memory store.
Example: remember: my name is Andrew
stated. The whole line you typed is kept as its quote, and the source is memproxy.chat request: remember: saved ... and memstore.py list.remember: lines in the chat history never save again.add approves immediately, as the manual for memstore.py says.| Version | Date | Change |
|---|---|---|
| 1.3.0 | 2026-10-27 | qwen_memproxy.py: a message starting with remember: saves the rest as an approved fact. |
| 1.2.1 | 2026-10-27 | qwen_memproxy.py: --drop-tools default is now per profile: all for 05b, runtime for 4b. |
| 1.2.0 | 2026-10-27 | qwen_memproxy.py: added --drop-tools (default runtime) to remove page tools before forwarding; the tools the page offers are logged once. |
| 1.1.0 | 2026-10-26 | qwen_memproxy.py: added --place system|user. QwenMemProxy.sh 1.0.2: reports FAILED and exits 1 when the program never starts listening. |
| 1.0.1 | 2026-10-26 | Per-request log line. QwenMemProxy.sh waits up to 30 s for start-up. |
| 1.0.0 | 2026-10-26 | First release of qwen_memproxy.py and QwenMemProxy.sh. |