Repository navigation
Conversation
Channel → Server 的轮次、定时任务和 Web 轮次原来都签发一枚短期 JWT(5–10 分钟) 随命令传给 Server。这套令牌是 agent 还是独立进程时用来回调 Server 的;agent 并入进程后,运行中已没有地方用它鉴权,只剩入轮时 recordRunResumeContext 校验 它、从中取出身份 claims 给停机恢复用。签发和使用之间一旦等太久就过期,于是: - Discuss 排队、历史加载、重组后入轮报 "invalid session credential for resume" (Memoh-Cloud #685); - follow-up 队列把整条命令连令牌原文写进数据库,排队超过 5 分钟的消息开始即失败; - 运行 5 分钟后再派生的子 agent,记录恢复上下文时用的是父 run 的令牌,同样失败。 改为: - turn.StartTurnCommand / ChatRequest / RunConfigRequest 去掉 Token、ChatToken、 SessionToken,改带 ActorAccountID:run 以哪个账号的权限运行。Channel 照原来 令牌的主体计算(bot 所有者,外部 runtime 会话取 runtime 所有者),Web 用登录 用户,定时任务用所有者,审批 / ask_user / 重试 / 编辑用响应人。内部 RPC 本身 已经认证,这个字段与 BotID、UserID 同等可信。 - 恢复上下文记录 ActorAccountID,恢复前照旧重新校验账号可用、对 bot 仍有聊天 权限;旧版本写下的 TokenClaims / ChatClaims 仍可读取。恢复不再依赖 JWT 密钥。 - 运行身份里的 SessionToken 改为 ActorAccountID,子 agent 继承它记录恢复上下文; 工具会话上下文、外部 runtime 输入里只作元数据的 SessionToken 删除。 - 删除只剩它自己引用的 chat_route 令牌:JWT 中间件对它跳过账号会话校验的分支、 无人调用的 POST /bots/{id}/channel/{platform}/send_chat,以及 Channel、Web、 定时任务里签发令牌的代码。重新生成 OpenAPI 与 SDK。 Refs felinics/Memoh-Cloud#685 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Author
Type
Summary
叠在 #1724 之上(base 为
refactor/context-prep)。#1724 合并后改为对 main。问题
Channel → Server 的轮次、定时任务和 Web 轮次原来都会签发一枚短期 JWT(5–10 分钟),随命令传给 Server。这套令牌是 agent 还是独立 TypeScript 进程时用来回调 Server 的(2026-02 引入);agent 并入 Go 进程(#264)之后,运行中已经没有地方用它鉴权:工具调用只把它当元数据,外部 runtime 回调工具靠的是不可猜的路由 key。唯一还校验它的是入轮时的
recordRunResumeContext(#1391),它从令牌里取出身份 claims 存给停机恢复用。签发和使用之间等太久,令牌就过期:invalid session credential for resume(Memoh-Cloud feat(web): open localhost links from markdown/terminal in the browser tab #685)。改动
turn.StartTurnCommand/ChatRequest/RunConfigRequest去掉Token、ChatToken、SessionToken,改带ActorAccountID:这一轮以哪个账号的权限运行。ActorAccountID;恢复前照旧重新校验账号可用、对 bot 仍有聊天权限。旧版本写下的TokenClaims/ChatClaims仍可读取。恢复不再依赖 JWT 密钥。SessionToken改为ActorAccountID,子 agent 继承它记录恢复上下文;工具会话上下文、外部 runtime 输入里只作元数据的SessionToken删除。POST /bots/{id}/channel/{platform}/send_chat;DiscussSessionConfig.Credentials改为ActorAccountID)。兼容性
send_chat接口删除是对外 API 的破坏性变更;仓库内(Web、桌面端、SDK 使用方)和 Cloud 仓库都没有找到调用方。packages/memoh之外没有使用这些令牌;同步到 Cloud 时仍需核对 fork 侧有无改动。Related Issues
Refs felinics/Memoh-Cloud#685
Validation
go test ./internal/... ./cmd/...全部通过。TestPostgres*:internal/agent/application(含停机恢复、决策续跑、历史重置后恢复)、cmd/agent(含 Discuss、定时任务端到端)、internal/chat/...、internal/schedule通过。golangci-lint对改动的包没有新增告警。Screenshots / Recordings
尚未完成。开发环境与真实 UI 验证还没做,需要验证:Web 聊天、Telegram(fake Bot API)chat 与 Discuss、Discuss 排队超过 5 分钟后入轮、停机恢复。验证完成前保持 draft。
Human QA
🤖 Generated with Claude Code