Repository navigation
fix: encode kind-2 interaction models as model targets in CreateInteraction - #323
likeravine233 wants to merge 4 commits into
Conversation
|
更新:经官网前端抓包(同一被迁移账户实测,见 #321),当前 PR 的路由修法可用但与官网行为不一致——前端实际调用 将把本 PR 改为编码器修复:路由不变(background=1 → 任务路径本身正确), |
…action Google migrated some accounts' gemini-4 models to the Interactions backend, setting catalog field79 to [background=1, kind=2]. The website creates these via CreateInteraction with the target at index 17 as ["models/X", genConfig] (same shape as CreateInteractionStream), then streams via GetInteractionStream. AIS encoded kind-2 models into the index-18 agent target, so upstream rejected with 'refers to a model, but was provided in the agent field'. - models.go: record field79 kind==2 as interaction_model capability (routing unchanged: background=1 still selects the task path) - interaction.go: EncodeCreateInteractionRequest branches on kind — kind-2 models encode the model target at index 17 with a generation config identical to the stream path; kind-1 agents keep the index-18 agent target - emit the field-53 video output format only for video-capable models - map interaction final state 6 (incomplete) to a length finish instead of a protocol error Verified on a migrated account against the website's own request capture and live traffic: gemini-4 family single/multi-turn all 200.
960420e to
b96a892
Compare
Interaction final status 2 (requires_action) ends the interaction after a function call. Decode call contents from the interaction steps and emit EventToolCall events with a tool_calls finish reason instead of failing with an unrecognized final state.
encodeModelInteractionTarget dropped request tools entirely so upstream never saw function declarations. Encode them at interaction field 7 with the shared tool encoder, only when the request declares tools.
…tent Catalog field-79 flags mark kind=2 models for the interaction path, but the flag is a frontend hint: GenerateContent is still accepted for these models (verified on a flagged account), and the interaction task path meters against a much smaller quota pool. The new config option lets users on flagged accounts keep tool calls and normal quota via the default path. Gate lives in interactionRoute so catalog parsing stays faithful; kind=1 agent tasks are unaffected.
背景与最新进展(给 reviewer 的上下文)问题来源:Google 正在按账户灰度迁移 gemini-4 系列到 Interactions 后端。被标记账户的 ListModels 目录中 field 79 变为 本 PR 的解法:忠实复刻官网前端 wire 格式,不做创造性绕过——
为什么需要 DISABLE_INTERACTION_MODELS(实测驱动,非推测):
验证状态(诚实边界):编码修复、requires_action 触发、429 行为、GenerateContent 可用性均为真实账户实测;requires_action 的 call 提取与任务路径 tools 编码未端到端验证(账户任务配额见底后无法触发真事件);GenerateContent 可用性为单账户单日样本,若 Google 后端转为硬拦截,本选项退化为无效但不影响默认行为。 关联调查记录:#321 评论(完整时间线与限额数据) |
|
今天之内我会修完,昨天抓包后就睡觉了;然后为了方便 这个PR不会合入,但最后给你加上contributor,感谢你的PR~ |
没关系,非常感谢老大辛苦维护项目 |
问题
Google 将部分账户的 gemini-4 系列迁移至 Interactions 后端后,ListModels field 79 标为
[background=1, kind=2]。AIS 把 kind=2 模型也按 agent 目标编码(interaction index 18:[名称,nil,config]),上游返回 400:'gemini-4-hydrogen' refers to a model, but was provided in the 'agent' field。证据(被迁移账户实测)
官网前端抓包:前端调用 CreateInteraction + GetInteractionStream,模型目标在 index 17:
目录 flag 分布:
[.,.,null,2](omni)走 CreateInteractionStream;[.,.,1,2](gemini-4)与[.,.,1,1](agent)都走 CreateInteraction+GetInteractionStream——路由没错,错的只是目标编码格式。修改内容
interaction_model能力位(路由不变,background=1 仍走任务路径)EncodeCreateInteractionRequest按 kind 分流——kind=2 在 index 17 写["models/X", genConfig](genConfig 与 CreateInteractionStream 同构:thinking level / 1 / max tokens),kind=1 维持 index 18 agent 目标[name,args,id?],发 EventToolCall + finish_reason="tool_calls";status 6(incomplete)映射为 length finishinteraction[7](共享 agentTools 编码器;未声明时不注入目录默认工具,与官网抓包一致)DISABLE_INTERACTION_MODELS(admindisable_interaction_models)——置位时 kind=2 模型不按目录标记走 interaction 路径,改与普通模型一样走 GenerateContent。拦截点在interactionRoute,目录解析保持原样;kind=1 agent 任务不受影响。用途:任务路径配额池实测远小于 GenerateContent(见 gemini-4 全系在部分账户被标为 field79 后台任务(kind=2)后,CreateInteraction 把模型名误写入 agent 槽位被上游 400 #321 评论),且 flagged 账户实测 GenerateContent 仍被服务端接受(单账户单日样本)验证
在被迁移账户(field79=
[.,.,1,2])实测:gemini-4 全系(hydrogen/argon)单轮、多轮、截断全部 200,路径与官网一致(CreateInteraction + GetInteractionStream);status 2 的 502 崩溃为实测触发;DISABLE_INTERACTION_MODELS置位后同账户 gemini-4 经 GenerateContent 返回 200(含 tool_calls)。边界:requires_action 的 call 提取与任务路径 tools 编码未在真实事件上端到端验证(该账户任务路径配额见底无法触发,见 #321 评论);GenerateContent 可用性为单账户单日样本。关联 issue:#321、#322