Repository navigation
fix(lane/gateway): 用户取消勾选的模型不再被周期探测与限流切换 (issue #103) - #116
Merged
LAGcomcom merged 1 commit intoOct 23, 2026
Merged
Conversation
模型页「选用」复选框写入 store.Config.HiddenModels,此前只用于从对外 /v1/models 列表剔除(server.go hiddenSet)。但 lane 层完全没读它:探测循环 (ProbeRound 遍历 l.catalog) 仍周期探测隐藏模型,限流切换的候选项选择 (nextCandidate 遍历 l.catalog) 仍会把隐藏模型自动切去真实访问——与「取消 勾选只是不对外展示」的预期不符。 修复:给 Lane 加 hidden 集合 + SetHidden(照 SetExposeRegion 的模式,整 map 原子替换,读取无需全程持锁)。 - ProbeRound:跳过 hidden 模型,不再烧探测槽位。 - nextCandidate:跳过 hidden 模型,禁止其作为限流/失败自动切换目标;直接 点名调用仍走原模型路径(不受影响)。 - server.New 启动即从 config 注入;adminModelVisibility 每次切换可见性即时同步。 新增 hidden_test.go 验证 nextCandidate 排除/恢复隐藏模型。
LAGcomcom
added a commit
that referenced
this pull request
Oct 23, 2026
Lands the ideas reviewed from #113-#116 as our own implementations, with tests written against the failure shapes rather than the patches: - usage: streaming usage snapshots fold per-field max instead of summation, which compounded repeated terminal frames up to 1400x (issue #105). The relay path shares the aggregation, and OpenAI's nested prompt_tokens_details.cached_tokens is now read (flat keys still win). - hidden models (issue #103): user-unchecked ids stop consuming probe rounds and stop acting as failover/throttle-switch candidates while staying directly callable; the set is seeded on boot and re-synced on visibility toggles and imports. An all-hidden round no longer reads as a quota wall. - dead egress: a tunnel-level failure (transport/timeout/reset) now books the node, not just the (exit, model) pair — two strikes inside the fail-memory window retire it from rotation until the dead-node probe answers; a raced success still resurrects it, and a probe revival clears the strike counter. - providers accept several API keys with per-request round-robin and classed cooldowns (credential 10m, 429 retry-after/10s, 5xx 15s; issue #104). Keys are write-only from the panel, masked in state and exports, and the single-key field stays the storage shape for one-key providers.
Owner
|
感谢贡献!隐藏模型不该继续消耗探测配额,这个方向完全正确。已按这个思路实现并合入 7eb328b:隐藏集合在启动时播种、切换与导入配置时即时同步,探测轮与 failover 候选都会跳过隐藏模型,显式点名仍然可达;顺带处理了全部隐藏时误判配额墙的边界。谢谢! |
ghshhf
pushed a commit
to ghshhf/zen-gate
that referenced
this pull request
Nov 3, 2026
上游把我们的 LAGcomcom#113-LAGcomcom#116、probe-verdicts 与 LAGcomcom#79 全部 revert 后按自己思路重写 (7eb328b / 0ae4c0b / 97eb4f3)。核对结果是重写版为我们需求的重写超集: usage 累加、hidden 探测、dead-egress、多 key 轮询、404 误判同样都修了, 另外还覆盖嵌套 cached_tokens、Kilo 判定过期、CodeArts 400、探测进度 (LAGcomcom#117)、渠道墙、前缀缓存、ZCode/TRAE/Ext 账号池、面板重构、macOS sing-box 资产选择、无头编译期隔离。 冲突处理:17 个冲突文件以上游为基线。依据是自研版在这些点上均被超集覆盖, 保留自研实现等于丢功能,而非"优先自己"能保住的东西——真要自主,从这次 合并之后的新功能开始(后续提交见)。 顺带清理:删除 internal/lane/hidden_test.go 与 usage_test.go,它们测的是 旧 []string 语义;上游 hidden_skip_test.go / http_usage_max_test.go 已等价 且更完整地覆盖同一行为。 验证:go build ./... 通过;go vet ./... 通过;lane/gateway/relay/subs/store 五个包测试全绿。
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.
解决的问题
issue #103:模型页取消勾选(隐藏)的模型,仍会被周期探测,并在限流/失败时自动切换去真实访问——与「取消勾选只是不对外展示」的预期不符。
根因
模型页「选用」复选框写入
store.Config.HiddenModels,此前只被server.hiddenSet()用于从对外/v1/models列表剔除。但 lane 层完全没读它:ProbeRound遍历l.catalog,仍周期探测隐藏模型;nextCandidate遍历l.catalog,仍会把隐藏模型自动切去真实访问。改动
给
Lane加hidden map[string]bool字段 +SetHidden(ids)方法(照SetExposeRegion模式,整 map 原子替换,并发读安全)。ProbeRound:跳过 hidden 模型,不再烧探测槽位。nextCandidate:跳过 hidden 模型,禁止其作为限流/失败自动切换目标。server.New启动即从 config 注入;adminModelVisibility每次切换可见性即时同步。设计保持一致:直接点名调用一个隐藏模型仍走原模型路径(不受影响),只有自动探测与自动切换被排除。
测试
新增
hidden_test.go:验证nextCandidate排除隐藏模型、解除隐藏后恢复。go build ./...与go test ./internal/lane/... ./internal/gateway/...全部通过。Closes #103