Skip to main content

How do I make a chat model like Qwen remember earlier messages?

Reuse the same Session ID on every run, or with the LLM Gateway resend the earlier messages or continue with previous_response_id.

A blank Session ID starts a new chat on every run, which is why a chat model "forgets". Reuse the same session:

  • On a model page: open Show advanced configurations, fill in Session ID (and User ID), and keep them the same for follow-up messages.

  • Run API: send the same session_id (up to 256 bytes, no line breaks) and user_id on every run. To continue after a tool call, send the earlier task's socketaccesstoken as previousTaskToken with the same session_id.

  • LLM Gateway: Chat Completions and Anthropic Messages don't store history, so resend earlier messages each time; Cursor, VS Code, Cline and Claude Code do this for you. The Responses API continues with previous_response_id from the same project and model, for a limited time and up to 32 responses in a chain.

The whole conversation must fit the model's context_length in /v1/models. Details: chat sessions, tool calls, Responses and our LLM Gateway guide.

Did this answer your question?