Skip to content

[Feature]: 模型对话时间超过一天,或者超长,需要重启gateway才能恢复响应 #203

@davidjohn2025

Description

@davidjohn2025

Summary

function createDeepseekWebStreamFn(cookieOrJson) {
let options;
try {
const parsed = JSON.parse(cookieOrJson);
if (typeof parsed === "string") options = { cookie: parsed };
else options = parsed;
} catch {
options = { cookie: cookieOrJson };
}
const client = new DeepSeekWebClient(options);
return (model, context, options) => {
const stream = createAssistantMessageEventStream();
const run = async () => {
try {
await client.init();
const sessionKey = context.sessionId || "default";
let dsSessionId = sessionMap$7.get(sessionKey);
let parentId = parentMessageMap.get(sessionKey);
if (!dsSessionId) {
dsSessionId = (await client.createChatSession()).chat_session_id || "";
sessionMap$7.set(sessionKey, dsSessionId);
parentId = void 0;
}
const messages = context.messages || [];
const systemPrompt = context.systemPrompt || "";
这段代码会新建一个web端会话session,但是这个id一旦生成,并不会更新,造成deepseek第二天会关闭这个sessionid,或者这个对话内容过多,deepseek会不再给回应,此时必须重启gateway才能重建id。建议这个id每过8点就重新生成,同时给这个session附加token计数属性,token超过计数80%后,就重新建立session,并把token计数返回给openclaw,和api的模式一样,避免openclaw随意压缩token,造成toolcall的消息遗失,执行toolcall失败

Problem to solve

function createDeepseekWebStreamFn(cookieOrJson) {
let options;
try {
const parsed = JSON.parse(cookieOrJson);
if (typeof parsed === "string") options = { cookie: parsed };
else options = parsed;
} catch {
options = { cookie: cookieOrJson };
}
const client = new DeepSeekWebClient(options);
return (model, context, options) => {
const stream = createAssistantMessageEventStream();
const run = async () => {
try {
await client.init();
const sessionKey = context.sessionId || "default";
let dsSessionId = sessionMap$7.get(sessionKey);
let parentId = parentMessageMap.get(sessionKey);
if (!dsSessionId) {
dsSessionId = (await client.createChatSession()).chat_session_id || "";
sessionMap$7.set(sessionKey, dsSessionId);
parentId = void 0;
}
const messages = context.messages || [];
const systemPrompt = context.systemPrompt || "";
这段代码会新建一个web端会话session,但是这个id一旦生成,并不会更新,造成deepseek第二天会关闭这个sessionid,或者这个对话内容过多,deepseek会不再给回应,此时必须重启gateway才能重建id。建议这个id每过8点就重新生成,同时给这个session附加token计数属性,token超过计数80%后,就重新建立session,并把token计数返回给openclaw,和api的模式一样,避免openclaw随意压缩token,造成toolcall的消息遗失,执行toolcall失败

Proposed solution

function createDeepseekWebStreamFn(cookieOrJson) {
let options;
try {
const parsed = JSON.parse(cookieOrJson);
if (typeof parsed === "string") options = { cookie: parsed };
else options = parsed;
} catch {
options = { cookie: cookieOrJson };
}
const client = new DeepSeekWebClient(options);
return (model, context, options) => {
const stream = createAssistantMessageEventStream();
const run = async () => {
try {
await client.init();
const sessionKey = context.sessionId || "default";
let dsSessionId = sessionMap$7.get(sessionKey);
let parentId = parentMessageMap.get(sessionKey);
if (!dsSessionId) {
dsSessionId = (await client.createChatSession()).chat_session_id || "";
sessionMap$7.set(sessionKey, dsSessionId);
parentId = void 0;
}
const messages = context.messages || [];
const systemPrompt = context.systemPrompt || "";
这段代码会新建一个web端会话session,但是这个id一旦生成,并不会更新,造成deepseek第二天会关闭这个sessionid,或者这个对话内容过多,deepseek会不再给回应,此时必须重启gateway才能重建id。建议这个id每过8点就重新生成,同时给这个session附加token计数属性,token超过计数80%后,就重新建立session,并把token计数返回给openclaw,和api的模式一样,避免openclaw随意压缩token,造成toolcall的消息遗失,执行toolcall失败

Alternatives considered

No response

Impact

这段代码会新建一个web端会话session,但是这个id一旦生成,并不会更新,造成deepseek第二天会关闭这个sessionid,或者这个对话内容过多,deepseek会不再给回应,此时必须重启gateway才能重建id。建议这个id每过8点就重新生成,同时给这个session附加token计数属性,token超过计数80%后,就重新建立session,并把token计数返回给openclaw,和api的模式一样,避免openclaw随意压缩token,造成toolcall的消息遗失,执行toolcall失败

Evidence/examples

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions