fix: 隐藏错误消息中的环境变量名 + 清理定时器优雅退出

Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/576c1b97-3ce4-4c28-99f1-9374e2320212

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-11 09:33:31 +00:00 committed by GitHub
parent fdc2ac0035
commit e8a6cb4f89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -147,7 +147,7 @@ function callDomesticLLM(modelConfig, messages) {
return new Promise((resolve, reject) => {
const apiKey = process.env[modelConfig.envKey] || '';
if (!apiKey) {
return reject(new Error(`API密钥未配置: ${modelConfig.envKey}`));
return reject(new Error('模型API密钥未配置'));
}
const url = new URL(modelConfig.endpoint);
@ -250,7 +250,7 @@ function getContext(userId) {
}
// 定期清理过期会话
setInterval(() => {
const _cleanupTimer = setInterval(() => {
const now = Date.now();
for (const [key, val] of contexts) {
if (now - val.lastActive > CONTEXT_TTL_MS) {
@ -258,6 +258,8 @@ setInterval(() => {
}
}
}, 300000); // 每5分钟清理一次
// 允许进程优雅退出
if (_cleanupTimer.unref) _cleanupTimer.unref();
/**
* 国内模型智能对话带自动降级