Skip to content

fix(ollama): preserve hosted subdomain model context - #144891

Merged
obviyus merged 1 commit into
mainfrom
fix/136257-ollama-hosted-context
Sep 11, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/136257-ollama-hosted-context

Conversation

@obviyus

@obviyus obviyus commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Onboarding a bare model name through a hosted service subdomain could save the local 32,768-token cap even when discovery reported a larger context.

Why This Change Was Made

Discovery and context preparation now share the hosted-hostname classifier. Transport policy keeps its separate HTTPS-origin checks. Obsolete test-routing references are removed.

User Impact

Hosted aliases preserve their advertised context; local models retain their existing cap. No configuration keys or migration change.

Evidence

Real noninteractive onboarding against a controlled endpoint reported 262,144 tokens. Before the fix, the hosted alias saved a 32,768-token cap; afterward it saved no local cap. The local control retained the cap. Focused provider and routing tests passed 400 and 480 cases. All 17 sanitized configs reached Gateway readiness with documented repairs and an exposure override. Live hosted inference and graceful shutdown were not established.

Related: #136257.

@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts extensions: ollama size: XS maintainer Maintainer-authored PR labels Sep 11, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 7:51 AM ET / 11:51 UTC.

ClawSweeper review

What this changes

The PR preserves advertised model context for hosted Ollama subdomains, shares the existing hostname classifier, extends preparation coverage, and removes obsolete tooling references.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main and v2026.9.4 still apply the local context cap to hosted subdomains. No introduced correctness or security defect was found, and the protected maintainer label also prevents cleanup closure.

Priority: P2
Reviewed head: ff7f9997b4a215a19e83aa2aa2f9b4607d594b39

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow owner-level repair with relevant production-boundary observations and useful regression controls; no actionable defect was found.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied before/after saved-config observations exercise the real onboarding entrypoint and Ollama context owner against a controlled HTTP fixture, showing the hosted cap removed and the local cap retained; they do not claim live Ollama Cloud inference.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied before/after saved-config observations exercise the real onboarding entrypoint and Ollama context owner against a controlled HTTP fixture, showing the hosted cap removed and the local cap retained; they do not claim live Ollama Cloud inference.
Evidence reviewed 8 items Current-main defect: The pinned main implementation checks only the canonical HTTPS origin before assigning contextTokens up to 32,768; bare models on api.ollama.com therefore take the local-cap path.
Latest-release comparison: The supplied latest release, v2026.9.4, contains the same canonical-origin check and local contextTokens assignment; the requested correction is not already present there.
Shared classification without transport-policy expansion: The introduced helper preserves discovery's existing exact-host or dot-delimited subdomain classification. Model preparation now consumes it, while stream.runtime.ts continues using isOllamaCloudOrigin for response-format and overflow request policy. No Codex dependency contract is involved.
Findings None None.
Security None None.

How this fits together

The Ollama plugin turns server-reported model capabilities into configuration used by onboarding and agent execution. Its context preparation distinguishes hosted models from local models that need a conservative memory allocation.

flowchart TD
  A[Configured Ollama endpoint] --> C[Hosted hostname classification]
  B[Reported model context] --> D[Model context preparation]
  C --> D
  D --> E[Hosted context preserved]
  D --> F[Local context capped]
  E --> G[Onboarding and agent configuration]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -7, Tests 0, Other -2. Total -9 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 3 12 19 -7
Tests 4 4 4 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 2 -2
Total 8 16 25 -9

Review metrics

None.

Technical review

Best possible solution:

Keep one plugin-owned hosted-hostname classifier for context preparation, preserve local caps and explicit configuration, and retain the separate transport-policy boundary.

Do we have a high-confidence way to reproduce the issue?

Yes: current-main source shows that a bare model on an Ollama subdomain receives the local cap, and the PR records matching before/after onboarding results. This read-only review did not execute the application or tests.

Is this the best way to solve the issue?

Yes: reusing discovery's existing hostname classification repairs the context decision at its shared owner without adding configuration or changing transport authorization.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7764767a88b3.

Labels

Label changes:

  • add P2: This corrects an unnecessarily restricted context budget for hosted Ollama aliases with a limited provider-specific blast radius.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied before/after saved-config observations exercise the real onboarding entrypoint and Ollama context owner against a controlled HTTP fixture, showing the hosted cap removed and the local cap retained; they do not claim live Ollama Cloud inference.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied before/after saved-config observations exercise the real onboarding entrypoint and Ollama context owner against a controlled HTTP fixture, showing the hosted cap removed and the local cap retained; they do not claim live Ollama Cloud inference.

Label justifications:

  • P2: This corrects an unnecessarily restricted context budget for hosted Ollama aliases with a limited provider-specific blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied before/after saved-config observations exercise the real onboarding entrypoint and Ollama context owner against a controlled HTTP fixture, showing the hosted cap removed and the local cap retained; they do not claim live Ollama Cloud inference.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied before/after saved-config observations exercise the real onboarding entrypoint and Ollama context owner against a controlled HTTP fixture, showing the hosted cap removed and the local cap retained; they do not claim live Ollama Cloud inference.

Evidence

What I checked:

  • Current-main defect: The pinned main implementation checks only the canonical HTTPS origin before assigning contextTokens up to 32,768; bare models on api.ollama.com therefore take the local-cap path. (extensions/ollama/src/provider-models.ts:456, 7764767a88b3)
  • Latest-release comparison: The supplied latest release, v2026.9.4, contains the same canonical-origin check and local contextTokens assignment; the requested correction is not already present there. (extensions/ollama/src/provider-models.ts:456, 3a9d69db306c)
  • Shared classification without transport-policy expansion: The introduced helper preserves discovery's existing exact-host or dot-delimited subdomain classification. Model preparation now consumes it, while stream.runtime.ts continues using isOllamaCloudOrigin for response-format and overflow request policy. No Codex dependency contract is involved. (extensions/ollama/src/defaults.ts:12, ff7f9997b4a2)
  • Registered preparation regression coverage: The existing test invokes the registered app-guided preparation hook and checks resulting configuration. Added cases cover hosted subdomains, a transport path, a nondefault port, and a lookalike hostname; the local control retains its 32,768-token cap. (extensions/ollama/index.test.ts:819, ff7f9997b4a2)
  • Production onboarding observations: The complete supplied PR body records real noninteractive onboarding against a controlled HTTP server: the baseline saved contextWindow 262144 with contextTokens 32768 for a hosted alias, while the candidate omitted that cap; the local control retained it. The body reports saved-config and HTTP-trace inspection, 400 Ollama cases, 480 routing cases, and readiness for 17 sanitized Gateway configurations. These are contributor-reported observations, not executions performed during this review. (ff7f9997b4a2)
  • Obsolete references verified: All four worker/test paths removed from tooling lists are already absent from the pinned main tree. The live models/auth.test.ts route remains. This patch removes stale references rather than deleting executable regression tests. (test/vitest/vitest.commands-light-paths.mjs:49, 7764767a88b3)

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@obviyus
obviyus merged commit 79bb0d2 into main Sep 11, 2026
158 checks passed
@obviyus
obviyus deleted the fix/136257-ollama-hosted-context branch September 11, 2026 12:00
@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator Author

Landed after clean exact-head review and green CI.

Proof: Real onboarding queried a controlled Ollama HTTP fixture and saved the resulting configuration. Independent acceptance inspected the complete CLI, HTTP, and saved-config records.

Endpoint Baseline saved context Candidate saved context
Hosted Ollama subdomain contextWindow 262144, contextTokens 32768 contextWindow 262144, no local cap
Local loopback control Existing local behavior contextWindow 262144, contextTokens 32768

The canonical HTTPS-origin transport policy remains unchanged. The stale setup worker/test and two deleted list-test routes are removed; the live auth route and assertion baseline remain.

Validation passed: 400 Ollama checks, 480 routing checks, and readiness for all 17 real-Gateway config fixtures. Three corpus fixtures needed forced teardown after the fixed grace period, so graceful shutdown and sustained performance are not claimed. This is controlled HTTP-fixture proof, not live Ollama Cloud inference.

vincentkoc added a commit that referenced this pull request Sep 11, 2026
Preserve the reviewed harness while incorporating the landed benchmark prerequisite.

Punchcard-Session: coral-orchard-orchard-d4

* commit '4407ed19ac63b1c1c84a0cfe6eb4bbeca9c2322c': (1196 commits)
  fix(perf): isolate benchmark subprocess transport (#144159)
  refactor(auth): await Copilot cache persistence (#144810)
  refactor(web-fetch): exercise URL normalization through the public tool (#144887)
  fix(ollama): preserve hosted subdomain model context (#144891)
  fix(doctor): explain Codex plugin health failures (#144813)
  fix(channels): honor pinned accounts in Mattermost model menus (#144880)
  fix(update): failed-update records hide the triggering error behind the excerpt tail (#144729)
  fix(logging): preserve OpenClaw package references in diagnostics (#144808)
  fix: retain plugin detail tab selections while inspection loads (#144647)
  fix: keep discovered models when sign-in tokens renew (#144861)
  fix(update): preserve local package overrides (#89985)
  fix(update): resolve compatibility bridges within the runtime graph (#144831)
  chore(i18n): refresh native locales (#144856)
  fix: preserve child signal termination during CLI respawn (#144838)
  fix(text): hide encoded MiniMax tool envelopes (#126307)
  fix(subagents): deliver child replies that match the empty placeholder (#130647)
  fix(cli): reject blank message channel selectors (#144802)
  fix(telegram): preserve mixed text order and pending stop (#144839)
  fix(memory): restore FTS fallback for same-name view collisions (#144783)
  chore(release): close out 2026.9.4 on main (#144708)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 12, 2026
Share hosted Ollama classification between discovery and context preparation so hosted subdomains retain advertised context. Remove stale routes for deleted setup and model-list tests.

Validated with real onboarding against hosted/local fixtures, registered provider and routing checks, and the real Gateway config corpus.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: ollama maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant