Skip to content

fix: use configured baseUrl for Ollama model discovery#8693

Closed
koushikkethamakka wants to merge 1 commit intoopenclaw:mainfrom
koushikkethamakka:fix/ollama-discovery-baseurl
Closed

fix: use configured baseUrl for Ollama model discovery#8693
koushikkethamakka wants to merge 1 commit intoopenclaw:mainfrom
koushikkethamakka:fix/ollama-discovery-baseurl

Conversation

@koushikkethamakka
Copy link

@koushikkethamakka koushikkethamakka commented Feb 4, 2026

Summary

Fixes #8663

Previously, discoverOllamaModels() used a hardcoded localhost URL (http://127.0.0.1:11434) regardless of user configuration. This caused model discovery to fail silently for remote Ollama instances, even when the user had correctly configured models.providers.ollama.baseUrl.

Changes

  • discoverOllamaModels() now accepts optional baseUrl parameter
  • buildOllamaProvider() passes configured baseUrl to discovery
  • resolveImplicitProviders() receives config and extracts Ollama baseUrl
  • Strips /v1 suffix from baseUrl when calling /api/tags endpoint

Testing

  • Existing tests pass
  • Tested with remote Ollama configuration

Before

# Config
models.providers.ollama.baseUrl: "http://remote-server:11434/v1"

# Discovery always hits localhost, fails
GET http://127.0.0.1:11434/api/tags → timeout/error

After

# Config  
models.providers.ollama.baseUrl: "http://remote-server:11434/v1"

# Discovery uses configured URL (with /v1 stripped)
GET http://remote-server:11434/api/tags → success

Greptile Overview

Greptile Summary

This PR threads the configured models.providers.ollama.baseUrl through provider resolution so Ollama model discovery (/api/tags) no longer always targets http://127.0.0.1:11434. It adds a baseUrl? parameter to discoverOllamaModels, passes config down from ensureOpenClawModelsJson to resolveImplicitProviders, and normalizes configured URLs by stripping a trailing /v1 when calling the Ollama-native discovery endpoint.

Overall it aligns implicit provider generation with user configuration, which fits the existing pattern where other providers (e.g., Copilot/Bedrock) accept config/env input during implicit resolution.

Confidence Score: 4/5

  • This PR is likely safe to merge and fixes the intended remote Ollama discovery behavior.
  • Changes are localized (provider resolution + discovery URL) and preserve existing defaults, but URL normalization is a bit ad-hoc and could produce awkward URLs or misleading logs in some configurations.
  • src/agents/models-config.providers.ts (Ollama URL normalization and discovery logging)

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@openclaw-barnacle openclaw-barnacle bot added the agents Agent runtime and tooling label Feb 4, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +392 to +394
const baseUrl = configuredBaseUrl ?? OLLAMA_BASE_URL;
const apiBaseUrl = baseUrl.replace(/\/v1\/?$/, "");
const models = await discoverOllamaModels(apiBaseUrl);
Copy link
Contributor

Choose a reason for hiding this comment

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

The /v1 stripping only removes an exact trailing /v1 or /v1/, but it won’t handle common variants like http://host:11434/v1/api (should probably stay intact) or http://host:11434/v1/ with extra whitespace, and it doesn’t normalize trailing slashes (can lead to //api/tags). Consider normalizing via new URL() and explicitly joining paths so discovery always hits exactly <root>/api/tags.

(If you want to keep regex-based logic, it may also be worth trimming and then removing a trailing / after the replacement.)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/models-config.providers.ts
Line: 392:394

Comment:
The `/v1` stripping only removes an exact trailing `/v1` or `/v1/`, but it won’t handle common variants like `http://host:11434/v1/api` (should probably stay intact) or `http://host:11434/v1/` with extra whitespace, and it doesn’t normalize trailing slashes (can lead to `//api/tags`). Consider normalizing via `new URL()` and explicitly joining paths so discovery always hits exactly `<root>/api/tags`.

(If you want to keep regex-based logic, it may also be worth trimming and then removing a trailing `/` after the replacement.)

How can I resolve this? If you propose a fix, please make it concise.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 4, 2026

Additional Comments (1)

src/agents/models-config.providers.ts
discoverOllamaModels always says "local instance" when data.models is empty, but this function now supports remote instances via baseUrl (see apiBaseUrl on src/agents/models-config.providers.ts:99). This log message will be misleading in the common remote-config case.

      console.warn("No Ollama models found on configured instance");
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/models-config.providers.ts
Line: 109:111

Comment:
`discoverOllamaModels` always says "local instance" when `data.models` is empty, but this function now supports remote instances via `baseUrl` (see `apiBaseUrl` on `src/agents/models-config.providers.ts:99`). This log message will be misleading in the common remote-config case.

```suggestion
      console.warn("No Ollama models found on configured instance");
```

How can I resolve this? If you propose a fix, please make it concise.

Previously, discoverOllamaModels() used a hardcoded localhost URL
(http://127.0.0.1:11434) regardless of user configuration. This caused
model discovery to fail silently for remote Ollama instances, even
when the user had correctly configured models.providers.ollama.baseUrl.

Changes:
- discoverOllamaModels() now accepts optional baseUrl parameter
- buildOllamaProvider() passes configured baseUrl to discovery
- resolveImplicitProviders() receives config and extracts Ollama baseUrl
- Strips /v1 suffix from baseUrl when calling /api/tags endpoint

Fixes openclaw#8663
@mattmiddlesworth
Copy link

This might fix my issue where I'm unable to connect to my remote Ollama farm

@danitt
Copy link

danitt commented Feb 13, 2026

just adding my support here - this 100% addressed my connectivity issue with VM Openclaw + local Ollama

thanks @koushikkethamakka for putting this up

@sebslight
Copy link
Member

Closing as duplicate of #10742. If this is incorrect, comment and we can reopen.

@sebslight sebslight closed this Feb 13, 2026
@vincentkoc
Copy link
Member

Merged in #29201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Ollama Discovery Always Uses Hardcoded Localhost URL, Ignoring Config

5 participants