Skip to content

修复同一 Provider 重复 endpoint 导致模型保存失败 - #610

Closed
Orsted290 wants to merge 39 commits into
MemTensor:v1.2.3from
Orsted290:fix-duplicate-openai-endpoint
Closed

Orsted290 wants to merge 39 commits into
MemTensor:v1.2.3from
Orsted290:fix-duplicate-openai-endpoint

Conversation

@Orsted290

Copy link
Copy Markdown
Contributor

问题定位

首次 API Key 登录或在模型库添加模型时,如果新模型与已有配置属于同一 Provider,且使用相同协议、API 地址、有效 API Key 和额外请求参数,前端仍可能为新模型生成另一个 endpoint ID。首次登录读取配置时,已有 API Key 会被脱敏;客户端无法直接用用户输入的明文 Key 与脱敏值判断 endpoint 是否相同,因此提交了重复定义。

连接测试只验证 API 地址和 Key 能否调用模型服务,不会写入模型目录,所以测试可以成功。点击保存后,后端原有的重复定义校验会抛出 Duplicate endpoint definition for Provider openai,导致配置保存失败,新模型没有落盘。

保存新模型分为两阶段:先创建模型 preset,再写入模型用途 assignment。只在后端合并 endpoint 还不够;如果前端仍使用原 endpoint ID 查找刚创建的 preset,第二阶段就无法正确引用服务端保留的 endpoint。

修复内容

  • 后端在写入模型目录前,根据 Provider、协议、规范化后的 API 地址、有效 API Key、额外请求头和请求体判断 endpoint 定义是否相同。相同定义保留一个 endpoint,并将关联模型的 endpoint 引用重定向到保留 ID;凭据或请求参数不同的 endpoint 仍分别保留。其他模型校验继续执行。
  • 前端在两阶段保存期间记录待创建模型的 endpoint 身份。首次保存后若服务端合并了 endpoint,前端根据 Provider、模型 ID、来源、能力,以及 endpoint 地址、协议和脱敏 Key,唯一解析服务端 preset ID,再使用该 ID 提交 assignment。若无法唯一匹配,仍会明确失败,避免 assignment 指向错误模型。
  • 增加后端 endpoint 合并、模型引用重定向、不同凭据保持独立,以及前端两阶段保存使用 canonical ID 的回归测试。

验证结果

  • 后端:npm run test -w @memmy/backend -- src/infrastructure/memmy-config/tests/model-config-catalog.test.ts — 17 项通过。
  • 前端:npm run test -w @memmy/frontend/desktop -- src/api/tests/config-client.test.ts — 10 项通过。
  • git diff --check upstream/v1.2.2...HEAD — 通过。
  • 桌面打包版隔离验收:预置已有 endpoint,再以相同测试 Key 添加 gpt-6-luna。连接测试成功,保存未再报重复定义;配置只保留一个 endpoint,新 preset 指向该 endpoint,重启后模型仍存在。验收使用临时应用副本、本地模型列表 mock 和 fake key,没有调用外部模型服务。

Anson-Se and others added 30 commits September 26, 2026 13:17
…mand

A turn routed as end_topic used to be dropped from L1 capture as a whole,
so feedback, work conventions and instructions sent together with the
closing words never reached L1, user memory or the episode reward.

Only a bare end-topic command ("结束会话" / "不聊了") is still kept out of
L1. Every other end_topic turn now goes through the same capture decision
as a normal turn; the closed episode waits for that decision before
reflection and reward are queued.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preserve complete extraction for PDF and Office documents and return bounded chunks with continuation offsets. Select PDF pages before pagination and keep continuation hints within the tool result budget.

Add regression fixtures, runtime recovery checks, reproducible benchmarks, and isolated account-model review scripts. Record 140 passing tests, typecheck results, and three successful live synthetic scenarios. Leave plain-text pagination and extraction caching outside this change.
A trailing newline was shown as an extra blank line, so patches against one-line memory files failed to match.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the long-document fix limited to the runtime change and its tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Every memmy-memory run reports memmy_cli_* events to the cloud analytics
endpoint. resolveCommandIdentity took the second positional word as
command_action unconditionally, which was meant for subcommands such as
`session close`. For search, add, get and delete that word is the search
query, the memory text or the memory id, so it was sent verbatim. An
unrecognized first word was also sent verbatim as command_group.

command_action is now reported only when the first word is a group with
subcommands (service, session, turn, raw) and the second word is one of
that group's known subcommands; raw methods match case-insensitively, as
runRaw does. An unrecognized first word is reported as command_group
"unknown". The known commands live in a small table in analytics.ts that
mirrors runCommand and mapTopLevelCommand. has_session_id and has_turn_id
are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The session close route only woke the auto worker when the close result
listed closed episodes, jobs, or scheduled evolution. For an L3 World
Model v2 session, closeSession also freezes the pending L3 evidence
batches and queues l3_world_model_update jobs, but it does not return
them. When the session's episode had already closed earlier (idle
timeout or end_topic), closedEpisodeIds was empty and nothing woke the
worker. The worker does not poll, so the new L3 jobs stayed queued until
an unrelated request happened to wake it.

The close route now always schedules the worker, as the token compaction
boundary already does after freezing batches. A close with no follow-up
work costs one empty drain. A new REST contract test closes an L3 v2
session whose episode had already ended and checks that the worker picks
up the frozen L3 job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Synchronize the main branch code to the v1.2.0 branch
App updates left previously installed Cursor, Claude Code, and Codex hooks on the first-install script. Startup now compares the stored hook fingerprint and reinstalls when it is missing or stale.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the hook revision test beside the Cursor resume test renamed on v1.2.1.

Co-authored-by: Cursor <cursoragent@cursor.com>
DeepSeek Harness no longer accepts a generic plugin message source, and completed assistant turns are recorded as assistant/message.

Co-authored-by: Cursor <cursoragent@cursor.com>
DeepSeek Harness rejects official model requests when an enabled plugin manifest has no version.

Co-authored-by: Cursor <cursoragent@cursor.com>
fix(dsh): restore Memmy plugin activation across supported DSH tags
fix: remove legacy memory embedding config
A stored fingerprint no longer counts as current unless the on-disk script and bridge match it, and the fingerprint is recorded only after the rest of the install succeeds.

Co-authored-by: Cursor <cursoragent@cursor.com>
Send account identity with plugin and scan events, and coerce boolean params so GA4 keeps the events.
fix(analytics): report each newly stored memory once
…ding

fix(documents): 支持长文档分段续读
…ry-repair-queue

fix: deprioritize startup summary repairs
…-worker

fix(memory): wake the worker after every session close
v1.2.2 requires the turn capture decision to return a non-empty l1.title
together with l1.summary. The mixed feedback-and-closing test stub only
returned a summary, so the capture decision threw and the closing L1 stayed
in resolving instead of being activated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and-action

fix(memory): stop sending CLI arguments as analytics command actions
@Orsted290
Orsted290 requested a review from ZongYue99 as a code owner October 12, 2026 06:59
@Orsted290
Orsted290 changed the base branch from v1.2.2 to v1.2.3 October 12, 2026 07:00
@Orsted290 Orsted290 closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants