Skip to content

feat(provider): Ollama 本地 Provider 与能力探测 #48

Description

@Qiyuanqiii

Parent: #35

问题概述 / Summary

为离线、本地优先场景实现 Ollama Provider,并对模型是否支持工具、JSON、视觉和上下文窗口进行显式探测,避免因“本地模型存在”就假设其具备完整 Agent 能力。

当前基线 / Current baseline

  • llm.Provider、Router 与 Model Registry 已留出 Ollama 扩展点。
  • 本地网络访问仍应走明确 allowlist,不应自动扫描 LAN。
  • 不同 Ollama 模型的工具与上下文能力可能不同。

范围 / Scope

  • 仅连接显式配置的 loopback Ollama endpoint。
  • 实现模型列表、chat、stream、usage 估算与错误映射。
  • 根据模型元数据/qualification 记录 tools、vision、JSON 和 context capabilities。
  • 不支持 Tool 的模型自动进入 no-tool 安全路径,而不是伪造调用。
  • 接入 CLI、HTTP/OpenAPI、Desktop 和 Router。
  • 提供下载/未安装/服务未启动的可解释诊断,但不自动执行安装或 pull。

非目标 / Non-goals

  • 不自动下载模型。
  • 不扫描局域网 Ollama 实例。
  • 不把本地模型视为可信模型或绕过 Prompt injection/Policy。

涉及目录 / Affected directories

  • internal/llm/
  • internal/modelregistry/
  • internal/application/
  • internal/policy/
  • internal/store/
  • internal/httpapi/
  • cmd/cyberagent/
  • web/src/
  • configs/

依赖 / Dependencies

  • 可与 OpenAI-compatible Provider 并行。
  • 复用现有 Provider qualification 与 Router contracts。

验收条件 / Acceptance criteria

  • 默认只允许显式 loopback endpoint;非 loopback、redirect 和代理绕过被拒绝。
  • model list、chat、stream、取消和服务不可达测试通过。
  • tools/vision/JSON/context capability 不明时按不支持处理。
  • no-tool 模型不会收到 Tool schema,也不会进入错误的 Tool loop。
  • 模型切换、资格状态与错误在 Desktop 中清晰显示。
  • 不自动安装 Ollama、pull model 或修改系统服务。
  • Fake server 测试可离线运行;可选真实本机 smoke 有清晰步骤。
  • go test、go vet、OpenAPI 与前端测试通过。

安全边界 / Security boundaries

“本地”只描述部署位置,不代表可信。输出仍需 Policy、redaction、budget 与 Tool Gateway。

Activity

  1. added
    enhancementNew feature or request
    help wantedExtra attention is needed
    goPull requests that update go code
    providerLLM provider and model runtime
    on Aug 13, 2026
  2. added a commit that references this issue on Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgoPull requests that update go codehelp wantedExtra attention is neededproviderLLM provider and model runtime

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions