feat(antigravity): add safetySettings controls and payload inspector - #409
Closed
Tungnamh9231 wants to merge 6 commits into
Closed
Tungnamh9231 wants to merge 6 commits into
Tungnamh9231 wants to merge 6 commits into
Conversation
- 默认保持原有行为:不发送 safetySettings;启用后复用现有 Default/Lite category,并支持 OFF/BLOCK_NONE - 支持按 canonical model 移除整个 safetySettings 或过滤指定 category,配置可持久化并支持热更新 - Safety 模型显示名从现有聊天模型映射反向解析,避免维护第二份 provider mapping
- 桌面端和移动端增加全局开关、threshold、模型规则、删除与保存入口 - 模型列表来自 fetchAvailableModels,规则内部绑定 Google 返回的 canonical model ID - Lite 不支持的 category 默认标红锁定;暂时不可用的已保存模型规则仍保留
- wrap_cli_request 在最终 provider 边界应用 safetySettings,确保本地 feature alias 使用同一 canonical model 规则 - 每次 stream/nonstream 真实发送前记录同一个 final_payload JSON body,不记录 Authorization 请求头 - 请求体日志独立于普通日志;contents 按 message/parts 层级展开,小对象保持紧凑显示
- Safety 配置直接合并到公共 saveConfig,与其他配置通过同一个 /config/save 保存 - 移除对全局 window.fetch 和 saveConfig 的临时包装,避免并发保存互相影响
- 两条及以上规则使用局部滚动区域,避免配置页随规则数量持续变长 - 增加已添加模型搜索和匹配计数,仅过滤显示,不修改已保存规则
github-actions
Bot
force-pushed
the
test/antigravity-safety-controls
branch
from
September 1, 2026 09:27
203c538 to
240b5d7
Compare
- 使用真实换行格式化 contents/message/parts,长文本按 Unicode 字符安全换行并保留原始换行 - WebSocket 按完整物理日志行缓冲超长 payload,避免 8KB 分块导致实时 JSON 解析失败 - JSON 解析失败时继续显示原始日志,不隐藏调试信息
Tungnamh9231
force-pushed
the
test/antigravity-safety-controls
branch
from
September 1, 2026 09:46
240b5d7 to
628db4e
Compare
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.
中文
这个 PR 主要补两个我在调 Antigravity 请求时一直缺的东西:按模型控制
safetySettings,以及在控制面板里直接看到最终真正发出去的请求体。safetySettings
目前仓库已经会按普通模型 / Lite 模型生成不同的 safety category,但没有地方控制这些内容最终要不要发、用什么 threshold,也不好处理某些模型对 category 支持不一致的情况。
这次在桌面版和移动版控制面板的 Antigravity 兼容设置里,放在
Antigravity切换凭证后面加了一个Antigravity safetySettings 兼容性控制面板。可以做这些事:
safetySettings,threshold 支持BLOCK_NONE/OFFfetchAvailableModels的结果,不另外维护一份模型表fetchAvailableModels里也不会被自动删掉默认仍然保持原来的行为:这个功能没有开启时,最终请求里不会带
safetySettings。开启后也继续复用仓库现有的 Default / Lite category 列表,没有再造一套 category 来源。规则是在 Antigravity 请求最终发送前应用的,所以抗截断、假流式这类本地 model 变体最终还是跟实际发送的 canonical model 使用同一条规则。过滤完一个 category 都不剩时会直接省略字段,不会发
safetySettings: []。Safety 配置现在也跟其它设置一样,直接合并到公共
saveConfig(),通过同一个/config/save保存,没有再对全局window.fetch做额外包装。请求体检查
另外在日志筛选里加了一个
请求体检查。Antigravity 每次真正执行 stream / non-stream HTTP 请求前,会把当次实际使用的
final_payload记成一条[PAYLOAD]日志。这样调 model mapping、safety rule、project 切换、tool config 之类的问题时,可以直接确认最后送到 provider 的 JSON 到底是什么。这里记录的是 JSON body,不记录
Authorizationheader。[PAYLOAD]在控制面板里单独显示,不混进普通的 All / Info / Warning;contents会按 message / parts 展开,长对话会比一整行 JSON 好看一些。实时日志会先把跨多个 8KB 读取块的长 payload 拼成完整一行再发给前端,避免半截 JSON 只能刷新后才正常显示。我把改动尽量限制在 Antigravity 请求和控制面板相关代码,默认不开 safetySettings 时不会改变原有请求行为。
English
This PR adds two things that were missing when debugging Antigravity requests: per-model
safetySettingscontrol and a way to inspect the actual final request body sent to the provider.safetySettings
The repo already builds different safety category lists for regular and Lite models, but there was no way to control whether those settings are sent, which threshold is used, or how to handle models that do not support the same set of categories.
I added an
Antigravity safetySettingspanel to the Antigravity compatibility settings section in both desktop and mobile control panels, directly after the existingAntigravity switch credentialoption.The panel allows you to:
safetySettingsglobally and chooseBLOCK_NONEorOFFfetchAvailableModelsinstead of maintaining another model listfetchAvailableModelsThe default behavior stays unchanged: when the feature is not enabled,
safetySettingsis omitted from the final request. When enabled, it reuses the existing Default / Lite category lists already in the repo rather than introducing another source of safety categories.Rules are applied right before the final Antigravity request is built, so local model variants such as anti-truncation or pseudo-streaming still follow the rule for the canonical model that is actually sent upstream. If filtering removes every category, the field is omitted instead of sending
safetySettings: [].Safety settings are saved the same way as the rest of the control-panel config now: they are merged into the existing
saveConfig()payload and sent through the same/config/saverequest. There is no globalwindow.fetchwrapping involved.Request body inspector
I also added a
请求体检查entry to the log filter.Right before each real Antigravity stream or non-stream HTTP request, the exact
final_payloadused for that attempt is logged with a[PAYLOAD]marker. This makes it much easier to check the final JSON after model mapping, safety filtering, project switching, tool config, and the other provider-boundary changes have already been applied.Only the JSON body is logged; the
Authorizationheader is not included. In the control panel, payload entries are kept out of the normal All / Info / Warning views, andcontentsis expanded by message / parts so multi-turn payloads are easier to read. For live logs, payload lines spanning multiple 8KB reads are buffered until the complete line is available, so the frontend never receives half of a JSON payload and only formats it correctly after a reload.The changes are scoped to the Antigravity request path and control panel, and the existing request behavior remains unchanged unless the new safetySettings option is enabled.