[PR #6911] [management, proxy] Add Ollama providers and model discovery to Agent Network #30016

Open
opened 2026-08-05 08:09:42 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6911
Author: @TechHutTV
Created: 7/26/2026
Status: 🔄 Open

Base: mainHead: feat/agent-network-ollama


📝 Commits (5)

  • 564abb6 Add self-hosted Ollama
  • a92cdb7 authentication semantics, API contracts, and tests
  • d3909e4 endpoint model discovery and proxy integration
  • 0463b30 Ollama Cloud provider integration and backend test coverage
  • fea1311 API-key normalization and model-discovery snapshot validation

📊 Changes

28 files changed (+4247 additions, -645 deletions)

View changed files

📝 management/internals/modules/agentnetwork/catalog/catalog.go (+90 -12)
management/internals/modules/agentnetwork/catalog/catalog_test.go (+96 -0)
management/internals/modules/agentnetwork/handlers/providers_discovery_test.go (+72 -0)
📝 management/internals/modules/agentnetwork/handlers/providers_handler.go (+60 -4)
management/internals/modules/agentnetwork/handlers/providers_validation_test.go (+47 -0)
📝 management/internals/modules/agentnetwork/manager.go (+274 -12)
management/internals/modules/agentnetwork/model_discovery_test.go (+248 -0)
management/internals/modules/agentnetwork/provider_auth_test.go (+124 -0)
📝 management/internals/modules/agentnetwork/synthesizer.go (+19 -9)
📝 management/internals/modules/agentnetwork/synthesizer_test.go (+99 -0)
management/internals/modules/agentnetwork/types/model_discovery.go (+19 -0)
📝 management/internals/modules/agentnetwork/types/provider.go (+11 -5)
📝 management/internals/modules/agentnetwork/types/provider_test.go (+42 -0)
📝 management/internals/modules/reverseproxy/proxy/manager.go (+6 -0)
📝 management/internals/modules/reverseproxy/proxy/manager/controller.go (+14 -6)
📝 management/internals/modules/reverseproxy/proxy/manager_mock.go (+15 -0)
management/internals/shared/grpc/model_discovery_test.go (+404 -0)
📝 management/internals/shared/grpc/proxy.go (+283 -22)
📝 management/internals/shared/grpc/proxy_test.go (+63 -0)
proxy/internal/modeldiscovery/discovery.go (+337 -0)

...and 8 more files

📄 Description

Describe your changes

Adds dedicated self-hosted Ollama and Ollama Cloud providers to Agent Network. Both providers reuse Ollama's OpenAI-compatible API, while keeping their deployment and authentication semantics separate:

  • Self-hosted ollama uses an operator-supplied endpoint and optional authentication.
  • Hosted ollama_cloud defaults to ollama.com and requires a Bearer API key.

The change also adds provider-scoped model discovery. Management resolves the persisted provider configuration and asks a capable proxy in the selected cluster to query the upstream endpoint. Discovery tries GET /v1/models first, with an Ollama-specific GET /api/tags fallback after 404 or 405, then returns a normalized model list to management.

Changes

  • Added dedicated ollama and ollama_cloud catalog entries with dynamic model lists.
  • Added catalog-owned authentication modes: required, optional, and none.
  • Made provider create/update validation and synthesized upstream credentials follow the selected catalog authentication mode.
  • Added has_api_key, auth_mode, and supports_model_discovery to the relevant API responses.
  • Added POST /api/agent-network/providers/{providerId}/discover-models.
  • Added correlated model-discovery requests and results to the existing management/proxy control stream, including proxy capability negotiation.
  • Restricted discovery to persisted provider settings and fixed endpoint paths, with timeouts, response limits, redirect protection, normalized output, sanitized errors, and admission control.
  • Added catalog, authentication, handler, manager, synthesizer, gRPC, and proxy discovery coverage.

Testing

Completed locally:

  • go test ./management/internals/modules/agentnetwork/... -count=1
  • go test ./proxy/internal/modeldiscovery -count=1

Still needed before merge:

  • Run the complete management and proxy CI suites.
  • Verify discovery and inference against a real self-hosted Ollama endpoint.
  • Verify discovery, non-streaming chat, and streaming chat using a real Ollama Cloud API key.
  • Confirm mixed-version behavior with a management server or proxy that does not advertise model-discovery support.

TBD

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change because endpoint, authentication, and model-discovery guidance is surfaced by the catalog-driven provider UI.

Docs PR URL (required if "docs added" is checked)

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

  • New Features
    • Added model discovery for supported providers, including OpenAI-compatible and Ollama endpoints.
    • Added a provider API endpoint to discover and return available models.
    • Added catalog metadata for authentication requirements and model discovery support.
    • Added optional authentication support for Ollama providers.
    • Provider responses now indicate whether an API key is configured.
  • Bug Fixes
    • Improved credential handling when updating providers, including preserving or clearing keys as appropriate.
    • Prevented stale proxy memberships from receiving updates.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6911 **Author:** [@TechHutTV](https://github.com/TechHutTV) **Created:** 7/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/agent-network-ollama` --- ### 📝 Commits (5) - [`564abb6`](https://github.com/netbirdio/netbird/commit/564abb660c9ada6a8c22135b1be222a23d50e96a) Add self-hosted Ollama - [`a92cdb7`](https://github.com/netbirdio/netbird/commit/a92cdb7dcd0335927e82ad54c127f0138ca660b5) authentication semantics, API contracts, and tests - [`d3909e4`](https://github.com/netbirdio/netbird/commit/d3909e4faf28ac8f481c679d6461f07088432f42) endpoint model discovery and proxy integration - [`0463b30`](https://github.com/netbirdio/netbird/commit/0463b30152223e4d0748b8d97ffdb8a37338a003) Ollama Cloud provider integration and backend test coverage - [`fea1311`](https://github.com/netbirdio/netbird/commit/fea131101d67626f25cfad44f064db0b155be350) API-key normalization and model-discovery snapshot validation ### 📊 Changes **28 files changed** (+4247 additions, -645 deletions) <details> <summary>View changed files</summary> 📝 `management/internals/modules/agentnetwork/catalog/catalog.go` (+90 -12) ➕ `management/internals/modules/agentnetwork/catalog/catalog_test.go` (+96 -0) ➕ `management/internals/modules/agentnetwork/handlers/providers_discovery_test.go` (+72 -0) 📝 `management/internals/modules/agentnetwork/handlers/providers_handler.go` (+60 -4) ➕ `management/internals/modules/agentnetwork/handlers/providers_validation_test.go` (+47 -0) 📝 `management/internals/modules/agentnetwork/manager.go` (+274 -12) ➕ `management/internals/modules/agentnetwork/model_discovery_test.go` (+248 -0) ➕ `management/internals/modules/agentnetwork/provider_auth_test.go` (+124 -0) 📝 `management/internals/modules/agentnetwork/synthesizer.go` (+19 -9) 📝 `management/internals/modules/agentnetwork/synthesizer_test.go` (+99 -0) ➕ `management/internals/modules/agentnetwork/types/model_discovery.go` (+19 -0) 📝 `management/internals/modules/agentnetwork/types/provider.go` (+11 -5) 📝 `management/internals/modules/agentnetwork/types/provider_test.go` (+42 -0) 📝 `management/internals/modules/reverseproxy/proxy/manager.go` (+6 -0) 📝 `management/internals/modules/reverseproxy/proxy/manager/controller.go` (+14 -6) 📝 `management/internals/modules/reverseproxy/proxy/manager_mock.go` (+15 -0) ➕ `management/internals/shared/grpc/model_discovery_test.go` (+404 -0) 📝 `management/internals/shared/grpc/proxy.go` (+283 -22) 📝 `management/internals/shared/grpc/proxy_test.go` (+63 -0) ➕ `proxy/internal/modeldiscovery/discovery.go` (+337 -0) _...and 8 more files_ </details> ### 📄 Description ## Describe your changes Adds dedicated self-hosted Ollama and Ollama Cloud providers to Agent Network. Both providers reuse Ollama's OpenAI-compatible API, while keeping their deployment and authentication semantics separate: - Self-hosted `ollama` uses an operator-supplied endpoint and optional authentication. - Hosted `ollama_cloud` defaults to `ollama.com` and requires a Bearer API key. The change also adds provider-scoped model discovery. Management resolves the persisted provider configuration and asks a capable proxy in the selected cluster to query the upstream endpoint. Discovery tries `GET /v1/models` first, with an Ollama-specific `GET /api/tags` fallback after `404` or `405`, then returns a normalized model list to management. ### Changes - Added dedicated `ollama` and `ollama_cloud` catalog entries with dynamic model lists. - Added catalog-owned authentication modes: `required`, `optional`, and `none`. - Made provider create/update validation and synthesized upstream credentials follow the selected catalog authentication mode. - Added `has_api_key`, `auth_mode`, and `supports_model_discovery` to the relevant API responses. - Added `POST /api/agent-network/providers/{providerId}/discover-models`. - Added correlated model-discovery requests and results to the existing management/proxy control stream, including proxy capability negotiation. - Restricted discovery to persisted provider settings and fixed endpoint paths, with timeouts, response limits, redirect protection, normalized output, sanitized errors, and admission control. - Added catalog, authentication, handler, manager, synthesizer, gRPC, and proxy discovery coverage. ### Testing Completed locally: - [x] `go test ./management/internals/modules/agentnetwork/... -count=1` - [x] `go test ./proxy/internal/modeldiscovery -count=1` Still needed before merge: - [ ] Run the complete management and proxy CI suites. - [ ] Verify discovery and inference against a real self-hosted Ollama endpoint. - [ ] Verify discovery, non-streaming chat, and streaming chat using a real Ollama Cloud API key. - [ ] Confirm mixed-version behavior with a management server or proxy that does not advertise model-discovery support. ## Issue ticket number and link TBD ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [X] Is a feature enhancement - [ ] It is a refactor - [X] Created tests that fail without the change (if possible) - [ ] This change does **not** modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — **OR** I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#discuss-changes-with-the-netbird-team-first). > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [X] Documentation is **not needed** for this change because endpoint, authentication, and model-discovery guidance is surfaced by the catalog-driven provider UI. ### Docs PR URL (required if "docs added" is checked) https://github.com/netbirdio/docs/pull/__ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added model discovery for supported providers, including OpenAI-compatible and Ollama endpoints. * Added a provider API endpoint to discover and return available models. * Added catalog metadata for authentication requirements and model discovery support. * Added optional authentication support for Ollama providers. * Provider responses now indicate whether an API key is configured. * **Bug Fixes** * Improved credential handling when updating providers, including preserving or clearing keys as appropriate. * Prevented stale proxy memberships from receiving updates. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:09:42 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#30016