openclaw - 💡(How to fix) Fix Bug: Brave web_search falsely rejects freshness, date_after/date_before, and ui_lang in llm-context mode [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#75068Fetched 2026-05-01 05:38:31
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
3
Author
Timeline (top)
commented ×1subscribed ×1

OpenClaw's web_search tool with Brave provider in llm-context mode artificially blocks parameters that the Brave LLM Context API endpoint fully supports. The validation logic in executeBraveSearch returns unsupported_* errors before the request is ever sent to Brave, even though the underlying runBraveLlmContextSearch function is already coded to pass these parameters through.

Error Message

// Line ~84-88 if (normalizedLanguage.ui_lang && braveMode === "llm-context") return { error: "unsupported_ui_lang", ... };

// Line ~90-95 if (rawFreshness && braveMode === "llm-context") return { error: "unsupported_freshness", ... };

// Line ~104-108 if ((rawDateAfter || rawDateBefore) && braveMode === "llm-context") return { error: "unsupported_date_filter", ... };

Root Cause

File: extensions/brave/src/brave-web-search-provider.runtime.ts (compiled to dist/brave-web-search-provider.runtime-*.js)

The executeBraveSearch function contains explicit hardcoded checks that reject these parameters when braveMode === "llm-context":

// Line ~84-88
if (normalizedLanguage.ui_lang && braveMode === "llm-context") return {
  error: "unsupported_ui_lang",
  ...
};

// Line ~90-95
if (rawFreshness && braveMode === "llm-context") return {
  error: "unsupported_freshness",
  ...
};

// Line ~104-108
if ((rawDateAfter || rawDateBefore) && braveMode === "llm-context") return {
  error: "unsupported_date_filter",
  ...
};

However, the downstream runBraveLlmContextSearch function already accepts and forwards freshness:

async function runBraveLlmContextSearch(params) {
  const url = new URL(BRAVE_LLM_CONTEXT_ENDPOINT);
  url.searchParams.set("q", params.query);
  if (params.country) url.searchParams.set("country", params.country);
  if (params.search_lang) url.searchParams.set("search_lang", params.search_lang);
  if (params.freshness) url.searchParams.set("freshness", params.freshness);  // ← already implemented!
  ...
}

The normalizeFreshness utility already supports Brave-native values (pd, pw, pm, py) and custom date ranges (YYYY-MM-DDtoYYYY-MM-DD), so no additional mapping is needed.

Fix Action

Fix / Workaround

  • Users cannot filter search results by recency in llm-context mode, forcing workarounds like embedding dates in the query string.
  • Users cannot use date range filters, even though the Brave API supports them perfectly.
  • This creates a capability regression compared to the standard Brave web mode.

Code Example

curl -s "https://api.search.brave.com/res/v1/llm/context?q=tech+news&freshness=pd&count=5" \
  -H "X-Subscription-Token: <BRAVE_API_KEY>"

---

await web_search({ query: "tech news", freshness: "pd", count: 5 });

---

{
  "error": "unsupported_freshness",
  "message": "freshness filtering is not supported by Brave llm-context mode. Remove freshness or use Brave web mode."
}

---

await web_search({ query: "tech news", date_after: "2026-04-01" });

---

// Line ~84-88
if (normalizedLanguage.ui_lang && braveMode === "llm-context") return {
  error: "unsupported_ui_lang",
  ...
};

// Line ~90-95
if (rawFreshness && braveMode === "llm-context") return {
  error: "unsupported_freshness",
  ...
};

// Line ~104-108
if ((rawDateAfter || rawDateBefore) && braveMode === "llm-context") return {
  error: "unsupported_date_filter",
  ...
};

---

async function runBraveLlmContextSearch(params) {
  const url = new URL(BRAVE_LLM_CONTEXT_ENDPOINT);
  url.searchParams.set("q", params.query);
  if (params.country) url.searchParams.set("country", params.country);
  if (params.search_lang) url.searchParams.set("search_lang", params.search_lang);
  if (params.freshness) url.searchParams.set("freshness", params.freshness);  // ← already implemented!
  ...
}

---

// In runBraveLlmContextSearch, add:
if (params.count) url.searchParams.set("count", String(params.count));
RAW_BUFFERClick to expand / collapse

Bug Report: Brave web_search falsely rejects freshness, date_after/date_before, and ui_lang in llm-context mode

Summary

OpenClaw's web_search tool with Brave provider in llm-context mode artificially blocks parameters that the Brave LLM Context API endpoint fully supports. The validation logic in executeBraveSearch returns unsupported_* errors before the request is ever sent to Brave, even though the underlying runBraveLlmContextSearch function is already coded to pass these parameters through.

Affected Parameters

ParameterOpenClaw ErrorBrave API SupportEvidence
freshnessunsupported_freshness✅ Full support (pd, pw, pm, py, custom ranges)Brave LLM Context docs
date_after / date_beforeunsupported_date_filter✅ Supported via freshness custom range (YYYY-MM-DDtoYYYY-MM-DD)Same docs
ui_langunsupported_ui_lang⚠️ Not listed in LLM Context params, but not rejected by APIDirect API test shows ui_lang is silently ignored, not error

Steps to Reproduce

1. Direct API call (works)

curl -s "https://api.search.brave.com/res/v1/llm/context?q=tech+news&freshness=pd&count=5" \
  -H "X-Subscription-Token: <BRAVE_API_KEY>"

Result: Returns structured JSON with recent results. ✅

2. Via OpenClaw web_search (fails)

await web_search({ query: "tech news", freshness: "pd", count: 5 });

Result:

{
  "error": "unsupported_freshness",
  "message": "freshness filtering is not supported by Brave llm-context mode. Remove freshness or use Brave web mode."
}

Same for date_after/date_before:

await web_search({ query: "tech news", date_after: "2026-04-01" });

Result: unsupported_date_filter

Root Cause Analysis

File: extensions/brave/src/brave-web-search-provider.runtime.ts (compiled to dist/brave-web-search-provider.runtime-*.js)

The executeBraveSearch function contains explicit hardcoded checks that reject these parameters when braveMode === "llm-context":

// Line ~84-88
if (normalizedLanguage.ui_lang && braveMode === "llm-context") return {
  error: "unsupported_ui_lang",
  ...
};

// Line ~90-95
if (rawFreshness && braveMode === "llm-context") return {
  error: "unsupported_freshness",
  ...
};

// Line ~104-108
if ((rawDateAfter || rawDateBefore) && braveMode === "llm-context") return {
  error: "unsupported_date_filter",
  ...
};

However, the downstream runBraveLlmContextSearch function already accepts and forwards freshness:

async function runBraveLlmContextSearch(params) {
  const url = new URL(BRAVE_LLM_CONTEXT_ENDPOINT);
  url.searchParams.set("q", params.query);
  if (params.country) url.searchParams.set("country", params.country);
  if (params.search_lang) url.searchParams.set("search_lang", params.search_lang);
  if (params.freshness) url.searchParams.set("freshness", params.freshness);  // ← already implemented!
  ...
}

The normalizeFreshness utility already supports Brave-native values (pd, pw, pm, py) and custom date ranges (YYYY-MM-DDtoYYYY-MM-DD), so no additional mapping is needed.

Impact

  • Users cannot filter search results by recency in llm-context mode, forcing workarounds like embedding dates in the query string.
  • Users cannot use date range filters, even though the Brave API supports them perfectly.
  • This creates a capability regression compared to the standard Brave web mode.

Proposed Fix

Option A (Minimal): Remove the braveMode === "llm-context" checks for freshness, date_after/date_before, and allow them to flow to runBraveLlmContextSearch just like they already do for runBraveWebSearch.

Option B (Complete): Also add count support to runBraveLlmContextSearch. Currently the function does not pass count to the Brave LLM Context API (which defaults to 20), while the standard web mode does pass it. OpenClaw caps count at 10 via resolveSearchCount, but the LLM Context query builder ignores it entirely.

// In runBraveLlmContextSearch, add:
if (params.count) url.searchParams.set("count", String(params.count));

For ui_lang: The Brave LLM Context API does not document this parameter. Suggest either:

  • Removing the unsupported_ui_lang block and letting the API silently ignore it, OR
  • Keeping the block but changing the error message to clarify it's an OpenClaw limitation, not a Brave API limitation.

References

Environment

  • OpenClaw version: 2026.4.26
  • Provider: Brave Search (mode: llm-context)
  • Verified with direct curl to api.search.brave.com/res/v1/llm/context

extent analysis

TL;DR

Remove the hardcoded checks in executeBraveSearch that reject freshness, date_after, date_before, and update runBraveLlmContextSearch to handle count parameter.

Guidance

  • Identify and remove the explicit checks in executeBraveSearch that block freshness, date_after, and date_before parameters when braveMode is "llm-context".
  • Update runBraveLlmContextSearch to include count in the URL search parameters.
  • Consider removing the unsupported_ui_lang block or updating its error message to reflect that ui_lang is not a documented Brave LLM Context API parameter.
  • Verify the changes by testing the web_search function with the previously blocked parameters.

Example

// In runBraveLlmContextSearch, add:
if (params.count) url.searchParams.set("count", String(params.count));

Notes

The proposed fix assumes that the Brave LLM Context API will silently ignore the ui_lang parameter. If this is not the case, additional error handling may be necessary.

Recommendation

Apply the workaround by removing the hardcoded checks and updating runBraveLlmContextSearch to handle the count parameter, as this will allow the web_search function to utilize the supported parameters of the Brave LLM Context API.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Bug: Brave web_search falsely rejects freshness, date_after/date_before, and ui_lang in llm-context mode [1 comments, 2 participants]