Skip to content

fix(huggingface): honor available provider capabilities - #129797

Merged
steipete merged 4 commits into
mainfrom
codex/qa-huggingface-live-provider-capabilities-20260826
Aug 26, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/qa-huggingface-live-provider-capabilities-20260826

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Hugging Face's inference-router catalog exposes context limits and tool support per backend, while its OpenAI-compatible endpoint chooses the fastest available backend by default and can select alternatives through routing policies or failover. Existing discovery copied the first backend's context limit and advertised tools even when an eligible backend explicitly rejected them.

Project the safe capability intersection at the owning Hugging Face discovery boundary:

  • Use the smallest positive context limit across every available, non-error backend.
  • Disable tools whenever any available backend explicitly reports supports_tools: false.
  • Preserve bundled model metadata, single tool-capable routes, unknown-only capabilities, errored-route exclusion, and existing static/default fallbacks.

Production delta: +23/-25 (net -2). Focused regression coverage: +173 lines.

Upstream contract

Hugging Face documents that its OpenAI-compatible router selects the fastest available provider by default, with explicit provider/policy selection and failover; it does not guarantee capability-aware routing for tool-bearing requests:

The live public catalog confirms why a union is unsafe: meta-llama/Llama-3.1-8B-Instruct advertises Novita at approximately 168 tokens/second with supports_tools: false, while its tool-capable DeepInfra backend reaches approximately 30 tokens/second. The documented default therefore selects the explicitly incompatible backend unless a capable provider is pinned.

Verification

  • Queried the live unauthenticated public router catalog and passed its response through the actual production discovery owner: 134 models, including 31 with at least one available route explicitly rejecting tools and five mixing tool-capable and tool-incapable routes.
  • Passed discovered live models through the real OpenAI-completions request builder: mixed-route Llama and GPT-OSS requests omit unsupported tool payloads; the single tool-capable DeepSeek R1 route retains its tools.
  • Verified real context corrections: Qwen 1,010,000 -> 262,144; Gemma 262,144 -> 131,072; DeepSeek V4 1,048,576 -> 512,000; bundled default DeepSeek R1 remains 64,000.
  • Captured fail-first owner regressions for both mixed-route orders and false-plus-unknown routes, then proved reversed route order, errored negative routes, unknown-only routes, positive-only routes, no-route/static fallback, bundled metadata, and existing policy/provider suffix behavior.
  • Ran six discovery, provider, transport, and agent suites: 86 tests passed.
  • Targeted type-aware lint, formatting, git diff --check, and fresh independent local plus complete-branch P1 reviews passed.
  • No authenticated account, user token, paid request, external mutation, or local user service was used.

Risk

Low: existing plugin-owned model projection only; no configuration, authentication, request-schema, storage, migration, or model-default changes. The conservative intersection resolves both ClawSweeper concerns without assuming an undocumented upstream router capability.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. 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 Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 2:44 AM ET / 06:44 UTC.

ClawSweeper review

What this changes

The PR projects Hugging Face route metadata into discovered model definitions, using the lowest usable context limit and hiding tools only when every usable route reports no tool support.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer confirmation: the current head resolves the earlier order-dependent context-limit finding, but the Hugging Face router contract that makes tool capability a union across unpinned routes could not be independently verified in this environment.

Priority: P2
Reviewed head: 62e1b0b55838e6ba64cf6e5ad989945537557262
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused repair and regressions address the prior finding cleanly; only the external router tool-selection contract remains to be confirmed.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body reports live-router evidence, though the reviewer could not independently reach that endpoint.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body reports live-router evidence, though the reviewer could not independently reach that endpoint.
Evidence reviewed 7 items Current-main defect: Current main still selects the first positive provider context limit, so feed order can advertise a larger window than another eligible route supports.
Current-head repair: The PR filters errored routes and uses the minimum positive route limit, making the projected context window independent of provider-array order.
Caller and owner boundary: Authenticated provider setup calls discovery and passes its resulting definitions directly into the Hugging Face OpenAI-compatible provider configuration.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs extensions/huggingface/models.test.ts

Result: PASS (completed)

[test] starting test/vitest/vitest.extension-providers.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129797-drMMit/target

 ✓  extension-providers  extensions/huggingface/models.test.ts (13 tests) 615ms
     ✓ uses the live route context for bundled models while preserving their catalog metadata  504ms

 Test Files  1 passed (1)
      Tests  13 passed (13)
   Start at  06:45:15
   Duration  5.34s (transform 3.52s, setup 1.21s, import 3.34s, tests 615ms, environment 0ms)

[test] passed 1 Vitest shard in 11.35s
[test] starting test/vitest/vitest.extension-providers.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129797-drMMit/target

 ✓  extension-providers  extensions/huggingface/models.test.ts (13 tests) 580ms
     ✓ uses the live route context for bundled models while preserving their catalog metadata  508ms

 Test Files  1 passed (1)
      Tests  13 passed (13)
   Start at  06:45:27
   Duration  3.14s (transform 1.29s, setup 578ms, import 1.81s, tests 580ms, environment 0ms)

[test] passed 1 Vitest shard in 9.18s

Assertions:

  • PASS expect_output: Test Files

How this fits together

The Hugging Face plugin fetches the inference-router catalog and produces model definitions used by provider setup and agent context budgeting. Those definitions affect the tools and request size OpenClaw advertises before the router selects a backend.

flowchart LR
A[Hugging Face router feed] --> B[Plugin model discovery]
B --> C[Aggregate route capabilities]
C --> D[Model definitions]
D --> E[Agent context budget]
D --> F[Provider request routing]
Loading

Decision needed

Question Recommendation
Is there sufficient Hugging Face router evidence that an unpinned request containing tools is routed only to providers whose feed entry has supports_tools enabled? Verify capability-aware routing: Record current router documentation or a redacted live request proving that tool-bearing requests avoid routes marked supports_tools: false.

Why: The changed metadata controls whether OpenClaw emits tool payloads, while the router’s selection semantics are external and were not independently reachable from this review environment.

Before merge

  • Resolve merge risk (P1) - The PR leaves tools enabled when any non-error route supports them; that is safe only if the Hugging Face router routes tool-bearing requests exclusively to tool-capable backends, a live dependency contract this review could not recheck because DNS was unavailable.
  • Complete next step (P2) - A maintainer must confirm the external router capability-routing contract before this provider-metadata change is ready to land.
Agent review details

Security

None.

PR surface

Source -2, Tests +143. Total +141 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 23 25 -2
Tests 1 143 0 +143
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 166 25 +141

Review metrics

Metric Value Why it matters
Production versus regression coverage production -2, tests +143 The repair is net-negative in production and adds focused route-order and capability regressions.

Stored data model

Persistent data-model change detected: vector/embedding metadata: extensions/huggingface/models.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify router tool selection before merge (recommended)
    Confirm with current provider evidence that tool-bearing unpinned requests cannot be assigned to a route reporting no tool support.
  2. Adopt conservative tool gating
    Require every eligible route to support tools if the router cannot provide that selection guarantee.

Technical review

Best possible solution:

Retain the minimum-context aggregation and land only after recording provider evidence that unpinned tool requests are capability-routed; otherwise make tool support conservative across all eligible routes.

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

Yes, source-reproducible: current main reads the first positive route context while the provider configuration uses the resulting logical model definition. The read-only review did not execute the regression test.

Is this the best way to solve the issue?

Unclear: taking the minimum positive context is the safe fix for unpinned route selection, but the permissive tool aggregation needs the router’s capability-routing contract to be the best solution.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0229fe7a2a90.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body reports live-router evidence, though the reviewer could not independently reach that endpoint.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This corrects provider discovery metadata that can affect model context budgeting and tool availability, with bounded impact.
  • merge-risk: 🚨 auth-provider: The change alters provider model capability metadata used to decide whether OpenClaw sends tool payloads and how it budgets requests.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body reports live-router evidence, though the reviewer could not independently reach that endpoint.

Evidence

What I checked:

Likely related people:

  • Peter Lee: Current-main blame attributes the existing model-discovery projection to this commit; local history is shallow, so earlier ownership could not be resolved. (role: recent main-line contributor; confidence: medium; commits: 89525828e0e8; files: extensions/huggingface/models.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record provider evidence that a tool-bearing unpinned request is never routed to a supports_tools:false backend.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-26T03:03:41.239Z sha 1c1e255 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T03:50:36.356Z sha 8a0f913 :: needs changes before merge. :: [P1] Use the smallest available route context limit

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 Aug 26, 2026
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@steipete
steipete merged commit 29b1664 into main Aug 26, 2026
102 checks passed
@steipete
steipete deleted the codex/qa-huggingface-live-provider-capabilities-20260826 branch August 26, 2026 07:42
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
)

* fix(huggingface): honor available provider capabilities

* fix(huggingface): preserve canonical model definition typing

* fix(huggingface): bound context to every available route

* fix(huggingface): require tool support across eligible routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: huggingface maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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