Repository navigation
fix(platform): 取凭据无响应时换新连接重试,回合内瞬时拒绝可重新获取 - #2786
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 4, 2026 14:22
Owner
Author
|
已合入,感谢。评审中记录的非阻断后续项(均为 P3,不影响本次合入):
|
Owner
Author
This was referenced Nov 4, 2026
|
🚀 Released in v3.57.1 |
DylanQiao
added a commit
to DylanQiao/botmux
that referenced
this pull request
Nov 10, 2026
回合开始时平台答复 not_authorized(含 consent_missing),本回合发布的拒绝原先对整个回合是终局:用户在平台授权、按拒绝文案「完成后直接让我重试」重试,同一回合内仍然 exit 77;中途回复又会被 Codex steer 进运行中的回合,新回合不会开始,只能等回合结束再发一条消息。 沿用 deepcoldy#2786 / deepcoldy#2807 的回合内重取机制,把 not_authorized 也登记为可重取: - 独立节奏:从拒绝本身起算,至少间隔 30 秒,每回合每工具最多 20 次(unavailable 的节奏不变); - 平台仍答 not_authorized 时保留拒绝、稍后再问;答复在「未授权 / 未同意」之间变化时重发对应文案并继续可重取; - 拿到 granted 才写入(同一 CAS、策略复查、撤销即停);not_teammate / forbidden 仍是本回合终局;单文件模型不变。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
背景
绑定了中心化平台的机器,回合开始时由 daemon
POST /v1/machine/credential-grant为触发人取 bytedcli / lark-cli 的短期凭据。线上出现过同一个 daemon 在一个下午里三次取凭据「6 秒内没有任何响应」被销毁(没有状态码),这一轮的 bytedcli 全部 exit 77;同一个 daemon 在别的群里同期取凭据是成功的。平台侧的访问日志里没有这几次请求,后两次失败都发生在上一次成功取凭据结束后 0.6–1.9 秒。根因
postJson走的是node:https的全局 agent。daemon 跑在 Bun 1.4.4 上,Bun 和 Node ≥19 的全局 agent 都默认 keep-alive,空闲约 5 秒内的下一次请求会复用上一条连接。用 Bun 1.4.4 对平台实测:「成功后 0.5–2 秒再发」的 160 次请求里有 159 次复用了旧连接;客户端约 5 秒后才关闭空闲连接(期间一直是 ESTAB,平台没发 FIN)。timeout选项是 socket 空闲超时,不是建连超时。复用到一条在路径上已经静默失效(对端/中间设备丢了状态却没回 RST)的连接时,请求发出去后一直没有任何回包,等满 6 秒才报「连接超时」。本地用一个「收下第 2 个请求但永不应答」的服务端可以稳定复现这一形状(6 秒、无状态码);agent: false时同一场景立即走新连接成功。改动
src/platform/platform-http.ts:postJson/getJson新增可选freshConnection(agent: false+Connection: close),缺省不变,bind/team-agents/issue等其它调用方行为不变。src/platform/credential-grant-client.ts:postJson新增可选signal),对端逐字节慢吐、socket 空闲超时触发不了时也不会超出总上限,也不会留着第一次请求继续打平台。src/core/turn-cli-identity.ts+src/core/dashboard-ipc-server.ts:proven 模型(wrapper 每次调用都向 daemon 取身份)下,如果这一轮发布的是「平台暂时不可用」的拒绝,wrapper 下一次取身份时 daemon 会重新向平台要一次:unavailable;「未授权 / 未同意 / 不是队友 / forbidden」这类针对人的结论仍对整轮生效,不重取。denied_platform_unavailable_retryable):告诉 agent 之后的调用会自动重新获取、隔十几秒再试一次即可,不要求用户重新登录;原文案「请停止自动重试」只在不会重取的情况(single 模型)继续使用。影响面
credentialSource为auto/platform的 bot 取 bytedcli / lark-cli 凭据的路径;未绑定或local的 bot 不走这里。验证
本地在 rebase 到最新 master 后的树上跑(master 新增的
pg依赖在 worktree 外单独bun install --frozen-lockfile后软链):新增用例:
变异复验(摘掉守卫或改反,均咬红):
freshConnection、去掉重试、去掉硬超时、去掉 CAS、去掉间隔限制、不登记瞬时拒绝、unavailable时删条目、去掉次数上限、去掉在途共享、IPC 路由不调用重取。postJson不接signal、路由不传当前配置。运行时:用 Bun 1.4.4 加载编译后的
dist/platform/credential-grant-client.js对平台发无效 machine token 的请求,三次均为一次请求即返回forbidden(401),请求后进程不残留连接。独立对抗复核
攻过的场景:人工中途干预(撤销授权、解绑、改配置、会话关闭、委托停止、同一轮重新发布)、多步写入只完成一半(bytedcli 与 Codebase 伴随身份、拒绝已写但未登记)、周期循环 × 等待窗口交叠(重取间隔、8 秒取凭据预算、wrapper 20 秒 IPC 超时、并发调用、续期 sweep、在途时回合结束)。全部用真实组件 + 可控时钟复现,问题清单与处理:
postJson接signal,硬超时到点中止并销毁请求复核确认成立的部分:回合材料被回收或会话关闭时不复活;新发布与委托停止时 CAS 不覆盖;总时长确实封在 8 秒内、无未处理 rejection、无遗留计时器;HTTP 状态不重试;Bun 下
agent:false+connection: close每次新建连接、不带该选项的调用仍复用;bind.ts等其它调用方行为不变;并发调用共享一次尝试;重试表有上限;平台凭据不进 bytedcli 续期跟踪(与首次发布一致)。已知限制
🤖 Generated with Claude Code