feat(models): execute Responses and validated streams with capability routing

This commit is contained in:
Agent Workbench Dev
2026-10-31 22:27:53 +08:00
parent 578cf88eca
commit eeb11d6a76
24 changed files with 856 additions and 52 deletions
+27
View File
@@ -0,0 +1,27 @@
# 模型协议与能力边界
1.17新增OpenAI Responses适配,保留既有Chat Completions。品牌、模型名称与声明不能替代检测。现有API代理可按实际协议添加;未知WorkBuddy登录态、Anthropic原生协议及视觉/音频输入仍未接入。
## 实际协议
Chat沿用messages与tool_calls/tool_call_id;Responses使用typed input/output Items,function_call.call_id与function_call_output严格配对,保留原用量字段。请求使用store:false,支持同一接口和模型下携带加密reasoning Items,换接口/模型时重新生成普通历史,不泄露私有Items。工具采用strict:false以保持现有可选参数契约。
混合协议或流式模型池封存每个成员实际请求变体;真正发送的请求另有原字节SHA、长度和Task/Run所属工件。历史纯Chat请求继续按原格式核对。预算按最大变体估算和最小成员容量保守预留;不把多线路变体总和当一次发送量。
SSE只显示有界进展。完整参数和终结核对前不派发工具;Chat须完整finish_reason及[DONE],Responses须completed且身份、参数和文本与原片段一致。收到流后断开、超时或协议失败不自动换成员重发。主动停止关闭原HTTP并释放租约。保存有界原响应工件;已知凭据会脱敏,原流SHA和脱敏后工件SHA分别保留。超过4MB则停止读取并明确标记捕获范围。
## 能力与检测
文本/工具保留旧连接的协议声明,流式/视觉/音频默认待验证。检测只在用户主动调用后发送合成输入,可能产生上游费用;不输入项目文件、不执行检测工具。文本应答不能证明工具能力,工具须返回要求的原调用及nonce,流式须走真实SSE并完整结束。结果绑定连接和凭据修订及原请求账本;变化后不再显示已验证。
选路复用原轮询、权重、粘连、租约和冷却。能力不符者在获取租约前排除,并在原Run记录具体原因;全部不符记为未派发,不产生上游用量。HTTP401/429、超时、中断及结果未知分别保留,不承诺上游永不中断。
## 来源
实际读取并据以实现的OpenAI官方资料:
- [Responses迁移](https://developers.openai.com/api/docs/guides/migrate-to-responses)
- [函数调用](https://developers.openai.com/api/docs/guides/function-calling)
- [Responses流式事件](https://developers.openai.com/api/docs/guides/streaming-responses?api-mode=responses)
以上是协议依据,不能证明任意代理完整兼容。专项使用自有loopback服务;真实模型工程效果和Purge收益仍按用户此前选择单独待验。
+2 -2
View File
@@ -1,6 +1,6 @@
# 1.17 执行草案:模型协议、流式执行与能力路由
# 1.17 执行计划:模型协议、流式执行与能力路由
接续已完成独立发行和正式部署的1.16手机伴随端。此文件只登记后续方案,不表示已实现或已开始产品变更;从已验收的本地Git基线开具体分支。继续保持原Task/Run、工具结果、项目字节、审批和数据,按切片开发、验证、回顾并本地提交。
接续已完成独立发行和正式部署的1.16手机伴随端。当前从299fb14在feat/model-protocols-1.17实施;A–D已实现并通过专项,E操作验收中,F完整发行待执行。完成情况以QA-1.17、task_plan和原证据为准。继续保持原Task/Run、工具结果、项目字节、审批和数据,按切片开发、验证、回顾并本地提交。
用户目标是让接入的多个模型在真实工程中稳定承担合适工作。当前基础是兼容Chat协议的多连接、轮询/权重、Run粘连、并发租约、冷却及请求账本,另有受控DeepSeek引擎桥;这些不证明所有品牌的原生协议、流式、视觉或语音都可用。WorkBuddy未知配置格式、未知登录态导入及真实Purge收益仍须独立核验。
+8
View File
@@ -7,3 +7,11 @@
新增Chat Completions/Responses协议登记和版本化能力声明。文本、工具、流式、视觉与语音分别显示声明、未知、不支持、已验证;后者绑定连接修订及凭据修订,客户端提交不能伪造。旧schema:1记录只读兼容,读取不迁移原记录,原DPAPI绑定仍使用原协议/接口/模型身份。流式开关默认关闭,必须先明确声明支持。
18/18相关检查通过,包含旧模型池/请求身份/导入事务/热升级以及新能力声明、失效、未知筛选和失败回滚。原TAP见[专项结果](model-protocols-a-specialists.txt)。本切片尚不代表Responses请求或流式已实现;它们在B/C独立验收。全阶段发行、UI与工程门槛仍待执行。
## B–D:实际协议、流式与能力选路
Responses的typed Items、原call_id配对、原用量与同线路reasoning续接完成;混合池逐线路封存实际请求。Chat原格式和历史证据继续核对。原429切换后保持Run粘连,原工具不会重放。实际HTTP的Chat/Responses SSE支持分片UTF8、参数增量、完整终结、断开和主动停止;半截参数不执行,断流/超时不自动换线路重发。原响应以有界字节工件保存,凭据脱敏前/后SHA分别保留。
相关恢复检查42/42通过;新增边界29/29、流式/手机投影/上下文38/38通过(这些范围有重叠,不相加)。原日志见[恢复专项](model-protocols-current-specialists.txt)、[边界专项](model-protocols-boundary-specialists.txt)、[投影与上下文](model-protocols-projection-specialists.txt)。新增验证包括原停用对象导致probe引用失效的修复、检测所属attempt精确绑定、原始畸形UTF8捕获、CR事件终结、超时关闭HTTP、自有CCSwitch SQLite/TOML Responses导入,全部使用自有loopback数据。原失败夹具与首次UI定位失败保留;后者为select隐式名称包含option文字,已增加明确aria-label,重新实际验收中。
E界面已构建,正在操作验收;F独立发行与正式部署未执行。协议实现不能代表视觉/音频已接入或真实模型自主工程能力已经通过。具体协议和来源见[协议边界](MODEL-PROTOCOLS.md)。
+6
View File
@@ -3,3 +3,9 @@
## A:能力来源与旧连接
保留原schema:1和默认Chat连接,新增的能力信息放在每个连接上。声明不能当成实测,实测必须跟随实际连接和凭据修订;未知视觉/音频保持未知,不从模型名猜测。原模型池/导入/热升级和能力专项18项通过,未访问正式Key或发送真实模型请求。B/C继续实现实际协议和流式,A通过不能代表它们已交付。
## B–D:原请求与执行边界
统一消息不能取代真正发送的请求。Responses和流式池各封存实际变体,并另记当前物理请求的SHA/字节;保留原工具call_id、reasoning与原用量。流式进展不进入工具执行,直到原终结与参数通过核对;断流/超时保留unknown不自动重放。原始Buffer捕获保持畸形字节,发生已知凭据脱敏时单列工件SHA。
回顾发现probe引用原可变连接时,toggle会同时更新比较两端,导致旧检测结论被错误接纳;改为连接快照并验证修订。原attempt通过progress身份绑定,避免并发任务改变账本末项。29项新增边界及38项关联投影/上下文检查通过。预算仍按所有成员容量保守取最小值,可能降低混合池可用容量;没有损失请求/审批边界,后续可按真实任务需求优化。E实际验收和F独立发行仍按计划执行。
@@ -0,0 +1,39 @@
✔ owned CC Switch SQLite imports the selected TOML Responses wire_api and leaves unknown clients untouched (1434.5284ms)
✔ Responses executes one original tool through Runtime, carries encrypted Items, reports raw usage and seals exact wire bytes (4628.0791ms)
✔ mixed-protocol pool keeps both actual variants and changes route on 429 without re-executing completed tools (4708.4754ms)
▶ Responses incomplete, failed, missing call identity and unsupported hosted outputs never dispatch a tool
✔ Reject {"body":{"id":"resp_owned","status":"incomplete","output":[{"type":"function_call","id":"fc_partial" (2367.0582ms)
✔ Reject {"body":{"id":"resp_owned","status":"failed","output":[{"type":"function_call","id":"fc_failed","cal (2476.4776ms)
✔ Reject {"body":{"id":"resp_owned","status":"completed","output":[{"type":"function_call","id":"fc_bad","cal (2317.129ms)
✔ Reject {"body":{"id":"resp_owned","status":"completed","output":[{"type":"computer_call","id":"not-supporte (2229.2344ms)
✔ Responses incomplete, failed, missing call identity and unsupported hosted outputs never dispatch a tool (9390.7418ms)
✔ wire adapter preserves tool IDs but never passes Responses-private Items to Chat or another endpoint (0.1644ms)
✔ connection JSON import accepts explicit Responses protocol and continues to reject unknown protocols without reading client sessions (1040.2795ms)
✔ capability routing skips text-only members before acquiring a lease and records exact refusal in the original Run (2401.3744ms)
✔ all incompatible members reject with no network request, no lease, preserved Task and explicit non-dispatched ledger (2350.372ms)
✔ explicit synthetic tool probe verifies only actual matching call, never executes it and loses verification on revision changes (1549.1779ms)
✔ plain text probe cannot verify tools; wrong tool nonce and client supplied evidence cannot claim verified support (1817.464ms)
✔ a disabled connection invalidates an in-flight probe even when toggle mutates its original registry object (925.1592ms)
✔ real Chat SSE carries UTF8 and split tool JSON; Runtime executes only after DONE, stores partial progress and original usage (4639.8283ms)
✔ Responses typed SSE validates original item identity, terminal data, raw usage and tool result pair (4264.8592ms)
✔ incomplete network stream retains unknown attempt and never automatically switches pool or dispatches fragment tools (2665.4274ms)
✔ stopping an active HTTP stream closes only original request and keeps partial text without executing tools (1507.8489ms)
✔ explicit streaming probe uses actual SSE despite unknown declaration and binds its own original attempt (840.1404ms)
✔ stream timeout closes the original HTTP response, preserves redacted capture and never retries (1045.3911ms)
✔ SSE accepts CR-only final event boundaries and retains exact invalid UTF8 bytes without dispatch (1.144ms)
▶ stream parser rejects truncation, finish length, malformed JSON, duplicate sequence, changed final item and oversized data
✔ reject 0 (0.2171ms)
✔ reject 1 (0.1405ms)
✔ reject 2 (0.1213ms)
✔ reject 3 (5.2154ms)
✔ reject 4 (0.1261ms)
✔ reject 5 (0.1235ms)
✔ stream parser rejects truncation, finish length, malformed JSON, duplicate sequence, changed final item and oversized data (6.4556ms)
ℹ tests 29
ℹ suites 0
ℹ pass 29
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 24266.1287
@@ -0,0 +1,52 @@
✔ schema1 connections remain readable without inventing observed capabilities or migrating original state (892.4845ms)
✔ protocol, unsupported capabilities and stream choice persist; client claims cannot forge verified evidence (966.5389ms)
✔ ability evidence belongs to exact connection and credential revision; unknown and unsupported reject required routing (0.3516ms)
✔ invalid declarations and inconsistent stream settings reject before registry, revision and credentials mutate (681.927ms)
✔ model registry keeps original credentials/endpoint intact, rejects stale edits, and forgets only volatile keys on restart (1259.4085ms)
✔ config import previews exact revisions, keeps secrets volatile, syncs only when enabled and preserves manual edits on conflicts (996.4614ms)
✔ real HTTP pool fails over 429 to another model and never repeats completed tools; attempts seal actual request bytes and Run identity (4172.9802ms)
✔ pool rotation and weights select members on new Runs; disabled and missing credentials are excluded without requests (5369.0176ms)
✔ 401 blocks the credential revision; updating the key restores availability without leaking error echoes (2136.1904ms)
✔ queued request cancellation and in-flight disable release only owned leases and do not dispatch another HTTP request (1285.1659ms)
✔ compiled model-center HTTP API persists public profiles, blocks forged origins, and local operations never invoke a model (2522.6777ms)
✔ model registry disk failures restore routing, pool profiles and credential references without partial updates (1125.4403ms)
✔ model selection and saved configuration commit together and failures preserve the original mode and endpoint (1857.4609ms)
✔ configuration imports roll back the entire batch and retain one usable preview after validation or commit failure (874.6812ms)
✔ Responses executes one original tool through Runtime, carries encrypted Items, reports raw usage and seals exact wire bytes (3872.5619ms)
✔ mixed-protocol pool keeps both actual variants and changes route on 429 without re-executing completed tools (3712.8468ms)
▶ Responses incomplete, failed, missing call identity and unsupported hosted outputs never dispatch a tool
✔ Reject {"body":{"id":"resp_owned","status":"incomplete","output":[{"type":"function_call","id":"fc_partial" (2077.5477ms)
✔ Reject {"body":{"id":"resp_owned","status":"failed","output":[{"type":"function_call","id":"fc_failed","cal (2176.6625ms)
✔ Reject {"body":{"id":"resp_owned","status":"completed","output":[{"type":"function_call","id":"fc_bad","cal (2038.6461ms)
✔ Reject {"body":{"id":"resp_owned","status":"completed","output":[{"type":"computer_call","id":"not-supporte (1629.5944ms)
✔ Responses incomplete, failed, missing call identity and unsupported hosted outputs never dispatch a tool (7923.2614ms)
✔ wire adapter preserves tool IDs but never passes Responses-private Items to Chat or another endpoint (0.1597ms)
✔ connection JSON import accepts explicit Responses protocol and continues to reject unknown protocols without reading client sessions (982.9388ms)
✔ capability routing skips text-only members before acquiring a lease and records exact refusal in the original Run (3118.5909ms)
✔ all incompatible members reject with no network request, no lease, preserved Task and explicit non-dispatched ledger (1579.9588ms)
✔ explicit synthetic tool probe verifies only actual matching call, never executes it and loses verification on revision changes (997.4663ms)
✔ plain text probe cannot verify tools; wrong tool nonce and client supplied evidence cannot claim verified support (1226.9391ms)
✔ real Chat SSE carries UTF8 and split tool JSON; Runtime executes only after DONE, stores partial progress and original usage (4102.3699ms)
✔ Responses typed SSE validates original item identity, terminal data, raw usage and tool result pair (3736.7539ms)
✔ incomplete network stream retains unknown attempt and never automatically switches pool or dispatches fragment tools (2254.8904ms)
✔ stopping an active HTTP stream closes only original request and keeps partial text without executing tools (1331.031ms)
▶ stream parser rejects truncation, finish length, malformed JSON, duplicate sequence, changed final item and oversized data
✔ reject 0 (0.6407ms)
✔ reject 1 (0.1739ms)
✔ reject 2 (0.2062ms)
✔ reject 3 (4.8471ms)
✔ reject 4 (0.1743ms)
✔ reject 5 (0.1468ms)
✔ stream parser rejects truncation, finish length, malformed JSON, duplicate sequence, changed final item and oversized data (6.8946ms)
✔ hot upgrade adopts a retained virtual data root without reopening SQLite or changing rows, Provider or routing (1591.9706ms)
✔ failed adoption restores the original virtual data-root name and original open database (834.5372ms)
✔ hot upgrade refreshes retained model and importer methods while preserving credential and routing objects (1088.6735ms)
✔ hot upgrade refuses active probes and restores retained model methods if installation fails (900.0117ms)
ℹ tests 42
ℹ suites 0
ℹ pass 42
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 33273.7612
@@ -0,0 +1,47 @@
✔ pairing is short lived, single-use, generation-bound and validates exact permissions (1107.2974ms)
✔ device transaction failure neither consumes the ticket nor leaves a credential (971.6891ms)
✔ devices have project and action boundaries; rotation, expiration, revocation and host changes reject old authority (1084.1224ms)
✔ persistent registry stores hashes and a bounded audit, never raw credentials (967.9301ms)
✔ real TLS verifies IP SAN, CA chain, encrypted restart and public fingerprint (1195.4954ms)
✔ TLS sealing failure leaves listener closed and no plaintext or successful TLS registration (968.7866ms)
✔ HTTP pairing is concurrent single-use; secure cookie and strict origin/host checks (1062.3071ms)
✔ gateway never exposes management routes, arbitrary assets or unpaired project data (1249.5189ms)
✔ authorized project events paginate from original seq without leaking other project events or payloads (1700.9864ms)
✔ remote task projection excludes raw model history, host configuration, tool input and credentials (1442.3281ms)
✔ permission checks apply to direct remote mutation, not only UI controls (1047.2542ms)
✔ approval fingerprint and exact task/revision are bound; duplicate requests never execute twice (1540.1497ms)
✔ unknown original operation is recorded and never replayed after response failure (1245.2744ms)
✔ revocation and gateway closure reject old access without invoking runtime stop (777.859ms)
✔ rate limits reject pairing brute force and do not persist candidate secrets (750.6093ms)
✔ real Windows CurrentUser DPAPI persists only a sealed CA and reopens it (2582.997ms)
✔ mobile approval executes the original Runtime command exactly once and rejects the later desktop decision (1981.9998ms)
✔ desktop rejection wins a concurrent mobile request and original command remains unexecuted (1623.7516ms)
✔ phone stop waits for the original process exit and prevents later heartbeats and command replay (2266.9916ms)
✔ Run replacement during parent-stop wait is rejected rather than stopping the new Run (631.3227ms)
✔ diff pages preserve source SHA; report reads verify blobs and exclude unrelated artifact kinds (959.4308ms)
✔ hot upgrade refuses an active gateway and restores closed gateway ownership on failure (640.9049ms)
✔ damaged device permissions or expiry fail closed and never overwrite the original registry (699.9645ms)
✔ device revocation destroys its actual authenticated TLS connection (790.7691ms)
✔ real Chat SSE carries UTF8 and split tool JSON; Runtime executes only after DONE, stores partial progress and original usage (4304.0643ms)
✔ Responses typed SSE validates original item identity, terminal data, raw usage and tool result pair (3748.2139ms)
✔ incomplete network stream retains unknown attempt and never automatically switches pool or dispatches fragment tools (2501.0255ms)
✔ stopping an active HTTP stream closes only original request and keeps partial text without executing tools (2356.3092ms)
✔ explicit streaming probe uses actual SSE despite unknown declaration and binds its own original attempt (1192.6798ms)
✔ stream timeout closes the original HTTP response, preserves redacted capture and never retries (1412.0866ms)
✔ SSE accepts CR-only final event boundaries and retains exact invalid UTF8 bytes without dispatch (1.9856ms)
▶ stream parser rejects truncation, finish length, malformed JSON, duplicate sequence, changed final item and oversized data
✔ reject 0 (0.3728ms)
✔ reject 1 (0.2031ms)
✔ reject 2 (0.1649ms)
✔ reject 3 (4.8382ms)
✔ reject 4 (0.1347ms)
✔ reject 5 (0.119ms)
✔ stream parser rejects truncation, finish length, malformed JSON, duplicate sequence, changed final item and oversized data (6.4917ms)
ℹ tests 38
ℹ suites 0
ℹ pass 38
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 29527.5584