fix(web): add crawl4ai to _is_backend_available + _get_backend chain - #51782
Closed
reneil1337 wants to merge 1 commit into
Closed
reneil1337 wants to merge 1 commit into
reneil1337 wants to merge 1 commit into
Conversation
Without this, web.extract_backend: crawl4ai is silently ignored — the dispatcher's _is_backend_available() returns False for "crawl4ai" (no case match) and falls through to searxng, reporting a misleading "SearXNG is a search-only backend" error even when CRAWL4AI_URL + CRAWL4AI_API_TOKEN are configured correctly. Crawl4AI's bundled plugin (plugins/web/crawl4ai/) has been dead code without this fix. Crawl4AI 0.9.0+ requires Bearer auth by default; both URL and token must be present before routing.
1 task
Collaborator
|
Thanks for tracing the old hardcoded backend gate. This is an automated hermes-sweeper review. The requested behavior is now implemented on
That generalized implementation covers a registered Crawl4AI provider without adding a vendor-specific branch, so this additive patch is redundant. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
web.extract_backend: crawl4ainow actually routes to the bundled Crawl4AI plugin instead of being silently ignored. Before this, the setting fell through to the searxng default and surfaced a misleading "SearXNG is a search-onlybackend" error — even with
CRAWL4AI_URL+CRAWL4AI_API_TOKENconfigured correctly.Root cause: the dispatcher in
tools/web_tools.pyenumerates every backend it knows about in two places, andcrawl4aiwas in neither._is_backend_available()(the explicit-config path) has a chain ofif backend == "..."checks for
exa,parallel,firecrawl,tavily,searxng,brave-free,ddgs,xai— but nocrawl4aicase, so it returnedFalseand the explicit config was discarded._get_backend()'sbackend_candidatestuple (thelegacy auto-detect/fallback path) likewise had no crawl4ai entry, so even a fully-credentialed setup could never auto-select it. The bundled plugin at
plugins/web/crawl4ai/was therefore dead code — present in the tree but unreachablefrom the dispatcher. Confirmed by reading both functions on
main;grep -n crawl4ai tools/web_tools.pyreturned zero matches before the fix.Changes
tools/web_tools.py—_is_backend_available(): add acrawl4aicase (afterddgs, beforexai) gating on_has_env("CRAWL4AI_URL") and _has_env("CRAWL4AI_API_TOKEN"). Crawl4AI 0.9.0+ requires Bearer auth by default, so both theURL and the token must be present before the dispatcher will route
/crawlcalls — a URL alone is not enough.tools/web_tools.py—_get_backend(): append("crawl4ai", _has_env("CRAWL4AI_URL") and _has_env("CRAWL4AI_API_TOKEN"))to thebackend_candidateschain, placed last so it never shadows an existing backend and only activates whennothing earlier matched. Same dual-credential gate as above.
Two hunks, 5 lines added. No behavior change for any existing setup — the new branches are dead unless both crawl4ai env vars are set, so installs without crawl4ai credentials resolve exactly as before (the legacy fallback still lands
on
firecrawl).Validation
grep -n crawl4ai tools/web_tools.py→ two matches (one per function):Behavior of both helpers under each credential state:
_is_backend_available("crawl4ai")_get_backend()firecrawl(legacy default, unchanged)CRAWL4AI_URLonlyfirecrawl(unchanged)CRAWL4AI_URL+CRAWL4AI_API_TOKENcrawl4aiTargeted suites pass with no regressions:
tests/tools/test_web_tools_config.py,tests/tools/test_web_providers.py,tests/tools/test_web_providers_ddgs.py→ 84 passed. No existing tests cover_is_backend_available/_get_backenddirectly, and per the mechanical, well-isolated nature of the change none were added.
Migration
Backward-compatible and dormant by default. Users upgrading get crawl4ai support automatically once they set
web.extract_backend: crawl4aiinconfig.yamland provideCRAWL4AI_URL+CRAWL4AI_API_TOKEN. No config changes arerequired for existing setups.