Skip to content

pref(provider):删掉产品不需要的driver capabilities值#225

Merged
phantom5099 merged 2 commits into
1024XEngineer:mainfrom
phantom5099:main
Apr 11, 2026
Merged

pref(provider):删掉产品不需要的driver capabilities值#225
phantom5099 merged 2 commits into
1024XEngineer:mainfrom
phantom5099:main

Conversation

@phantom5099

@phantom5099 phantom5099 commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator

变更说明

本次改动的目标是移除 provider 层中已经失去实际区分意义的 DriverTransportCapabilities 及其配套逻辑。
在当前项目范围内,正式支持的 driver 数量有限,且都应直接实现统一的 GenerateDiscoverModels 合同。继续保留一组几乎总是被写成固定值的 capabilities 字段,只会形成重复真相,增加 runtime、catalog、registry 与测试层的维护负担。

因此,本次改动将 capabilities 从“driver 元数据声明”收缩回“具体 driver 实现与运行时错误本身”,让系统重新以统一合同、显式错误和模型能力提示为主,而不是依赖额外的布尔字段做分流。

主要改动

  • 删除 internal/provider/contracts.go 中的 DriverTransportCapabilities 定义。
  • 删除 internal/provider/registry.goDriverDefinition.Capabilities 字段及对应查询逻辑。
  • 删除 internal/provider/openaicompat/driver.go 中的 capability 声明。
  • 删除 internal/runtime/runtime.gointernal/runtime/compact_generator.go 中基于 capability 的运行前预检查。
  • 删除 internal/provider/catalog/service.go 中基于 ModelDiscovery 的判断分支,统一改为仅按 driver 是否已注册决定是否进入 discovery 合同。
  • 删除与 capabilities 相关的单元测试、测试桩与断言,避免测试继续维护一套已经失效的概念。

预期收益

  • 去掉重复表达的 driver 状态,减少“实现是真相、capabilities 又是另一套真相”的维护风险。
  • 收敛 provider -> registry -> runtime -> catalog 之间的职责边界,减少不必要的元数据耦合。
  • 让 driver 是否支持某项行为回到实现本身和显式错误上,降低抽象层次混乱带来的心智负担。
  • 为后续接入 openai-responsegeminianthropic 等主流 driver 保持更短、更直接的接入路径。
  • 简化测试体系,避免继续为低价值布尔字段构造桩逻辑和前置断言。

@codecov

codecov Bot commented Apr 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

fennoai[bot]

This comment was marked as outdated.

fennoai[bot]

This comment was marked as outdated.

fennoai[bot]

This comment was marked as outdated.

fennoai[bot]

This comment was marked as outdated.

fennoai[bot]

This comment was marked as outdated.

@phantom5099

Copy link
Copy Markdown
Collaborator Author

/review codex

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found in the current PR head.

Validated the updated discovery contract (Register() now requires Discover) and reran the affected provider/runtime test suites (go test ./internal/provider/... ./internal/runtime/...).

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a couple of regressions from removing the driver capability contract. The main issue is that the new code no longer preserves an explicit "no discovery / no transport" state, so some failures move from deterministic preflight checks to later provider invocations.

if driver.Build == nil {
return fmt.Errorf("provider: driver %q build func is nil", driver.Name)
}
if driver.Discover == nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-requiring Discover here removes the only way to represent a generate-only driver. After this change, callers have to register a stub discover function, and catalog.Service will treat the driver as discovery-capable on every cache miss/background refresh. That reintroduces ResolveDiscoveryConfig/API-key failures for providers that should have stayed on configured or default models, which is exactly the behavior the deleted catalog tests were protecting against.

return nil, err
}

modelProvider, err := s.providerFactory.Build(ctx, runtimeCfg)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the transport preflight here means Run now always builds the provider and calls Generate, even when the driver cannot actually stream tool calls. That turns a deterministic contract error into a later provider/network failure (or silent tool dropping) after we've already crossed the provider boundary. The deleted runtime tests covered this regression; if DriverTransportCapabilities is going away, runtime still needs another fail-fast way to reject unsupported streaming/tool transport before invocation.

@@ -42,9 +42,6 @@ func (g *compactSummaryGenerator) Generate(ctx context.Context, input contextcom
strings.TrimSpace(g.providerConfig.APIKey) == "" {
return "", errors.New("runtime: compact summary generator provider config is incomplete")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same regression exists in compact generation: without the old streaming capability check, we now invoke the provider and only fail after the call returns, often as a generic stream/protocol error. That makes unsupported drivers look like flaky runtime failures instead of a clear configuration/contract problem.

@phantom5099 phantom5099 merged commit 066eb87 into 1024XEngineer:main Apr 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant