Skip to content

[Feature]: 对齐“测试连接”和“实际调用”链路 / Ensure connection-test and actual-invocation parity #216

@Sun-sunshine06

Description

@Sun-sunshine06

[Feature]: 对齐“测试连接”和“实际调用”链路 / Ensure connection-test and actual-invocation parity

Problem / pain point / 问题

当前“测试连接”与“实际调用”并不总是走同一套有效 provider contract,因此容易出现误判:

  • 测试连接通过,但真实 generate 失败
  • 测试连接失败,但真实调用其实可用
  • /models 探测、wire 选择、baseUrl 规范化、keyless 判定、OAuth / Bearer 认证处理不完全一致
  • active provider 的解析、renderer 传入值覆盖、真实调用时的 baseUrl snap-to-config 逻辑,并没有完整复用到测试链路

Today the connection-test path and the real invocation path do not always share the same effective provider contract, which creates false positives and false negatives:

  • connection test passes while real generate fails
  • connection test fails even though real invocation works
  • /models probing, wire selection, baseUrl normalization, keyless handling, and OAuth / Bearer auth are not fully aligned
  • active-provider resolution and runtime-only config snapping are not consistently reused by connection tests

Proposed solution / 方案

把“测试连接”升级成“对真实调用链路的低成本验证”,而不是一条独立的近似探测路径。

Turn connection testing into a low-cost validation of the real invocation contract rather than a separate approximate probe.

具体包括:

  • 提炼共享的 “effective provider contract” 解析层
  • 让测试链路与运行链路复用相同的 provider 解析、auth/header、baseUrl、wire、keyless、OAuth 逻辑
  • /models fallback、chat/completions / responses 探测、以及 runtime 实际发送条件做显式对齐
  • 在无法完全复用真实请求时,返回结构化“哪里与真实调用可能分叉”的原因
  • 为“test-pass / runtime-fail”和“test-fail / runtime-pass”建立回归测试

Alternatives considered / 备选方案

  • 继续增强现有 diagnostics,但保留独立探测路径

    • 缺点:可以减少提示不清,但不能消除链路分叉本身
  • 直接用一次完整生成来代替测试连接

    • 缺点:成本高、速度慢、还可能产生副作用
  • Keep improving diagnostics while preserving a separate probe path

    • Rejected because it improves hints but does not remove the divergence
  • Replace connection testing with a full real generate call

    • Rejected because it is slower, costlier, and may have side effects

Scope / 范围

Provider / model

Acceptance criteria / 验收标准

  • connection:v1:test-active 与实际 generate 共享同一套 active provider 解析语义
  • connection:v1:test-provider 与真实运行共享同一套 auth、header、baseUrl、wire、keyless 规则
  • /models fallback 与真实 wire 行为的关系被显式定义,而不是只靠局部 probe 经验
  • ChatGPT Codex OAuth、keyless proxy、OpenAI-compatible gateway 都有 parity 覆盖
  • 至少覆盖以下回归场景:
    • test passes but runtime fails because effective wire / auth / baseUrl differs
    • test fails but runtime succeeds because /models is missing while inference works
  • renderer 能收到结构化结果,明确区分“可连通但与实际调用不一致”

Likely touchpoints / 可能涉及

  • apps/desktop/src/main/connection-ipc.ts
  • apps/desktop/src/main/index.ts
  • apps/desktop/src/main/provider-settings.ts
  • apps/desktop/src/main/resolve-api-key.ts
  • packages/core/src/index.ts
  • packages/providers/src/index.ts

Related issues / 相关 issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttriageAwaiting maintainer review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions