Repository navigation
Closed
Closed
Copy link
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Description
Summary
OpenClaw web search is configured to use the Gemini provider. Provider-specific validation errors confirm requests are reaching the Gemini-backed provider, but plain searches fail with:
Gemini API error: malformed JSON response
Environment
- OpenClaw version: 2026.5.28 (e932160)
- Installed npm package: openclaw@2026.5.28
- Platform: Windows / PowerShell
- Config path:
C:\Users\Porygon\.openclaw\openclaw.json - Relevant config:
{
"tools": {
"web": {
"search": {
"provider": "gemini",
"enabled": true
}
}
},
"plugins": {
"entries": {
"google": {
"enabled": true,
"config": {
"webSearch": {
"apiKey": "[configured]"
}
}
}
}
}
}Reproduction
Using the OpenClaw web_search tool:
- Search with a country filter:
{
"query": "OpenClaw Gemini web search test current date May 31 2026",
"count": 3,
"country": "US"
}Result:
{
"error": "unsupported_country",
"message": "country filtering is not supported by the gemini provider. Only Brave and Perplexity support country filtering.",
"provider": "gemini"
}- Search with a language filter:
{
"query": "OpenClaw Gemini web search test current date May 31 2026",
"count": 3,
"language": "en"
}Result:
{
"error": "unsupported_language",
"message": "language filtering is not supported by the gemini provider. Only Brave and Perplexity support language filtering.",
"provider": "gemini"
}- Search without unsupported filters:
{
"query": "OpenClaw Gemini web search test current date May 31 2026",
"count": 3
}Result:
Gemini API error: malformed JSON response
- Minimal plain search:
{
"query": "current date today",
"count": 1
}Result:
Gemini API error: malformed JSON response
Expected Behavior
For plain searches without unsupported filters, the Gemini provider should return normalized search results or a structured provider/API error.
Actual Behavior
Plain Gemini-backed web searches fail with Gemini API error: malformed JSON response.
Notes
The unsupported_country and unsupported_language responses indicate the request is reaching the Gemini provider path. The failure appears to occur when parsing or normalizing the successful Gemini search response.
Reacted by clawsweeper
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Type
Fields
Priority
None yet
Activity
clawsweeper commentedon May 31, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed May 31, 2026, 1:47 AM ET / 05:47 UTC.
Summary
Keep open: current main still contains the Gemini web_search plain-query path that can emit the reported malformed JSON error, and the related issues in the context cover different Gemini/web_search problems rather than this plain-search failure.
Reproducibility: no. high-confidence live reproduction was run in this read-only review. The reporter provides concrete v2026.5.28 steps, and current source still contains the same plain Gemini search path that emits the exact malformed JSON error when the provider response does not match the expected object shape.
Ways to help us reproduce this
Next step
Manual review should capture or run a live Gemini plain-search response before choosing the parser/API repair; the source path is narrow but the failing response shape is not in the issue.
Review details
Best possible solution:
Fix the Gemini web_search provider against the live plain generateContent response shape so it returns wrapped content and citations when grounded, or a structured provider/API error when Gemini returns a valid but unusable response.
Do we have a high-confidence way to reproduce the issue?
No high-confidence live reproduction was run in this read-only review. The reporter provides concrete v2026.5.28 steps, and current source still contains the same plain Gemini search path that emits the exact malformed JSON error when the provider response does not match the expected object shape.
Is this the best way to solve the issue?
Yes on direction, unclear on exact patch. The best repair is narrow in the Google plugin runtime/tests, but it should be based on a captured live response or official contract variant rather than guessing a new response shape.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 0303f3a8f086.
Label changes
Label changes:
P2: This is a normal-priority provider bug with a concrete repro on the latest release and limited blast radius to Gemini-backed web_search.impact:other: The issue breaks a maintainer-visible web_search provider path, which is outside the more specific owned impact labels.issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.clawsweeper:needs-live-repro: Current issue advisory state selects this label.clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.Label justifications:
P2: This is a normal-priority provider bug with a concrete repro on the latest release and limited blast radius to Gemini-backed web_search.impact:other: The issue breaks a maintainer-visible web_search provider path, which is outside the more specific owned impact labels.Evidence reviewed
What I checked:
unsupported_country/unsupported_languageresponses before making a network call, matching the reporter's evidence that the request is routed to the Gemini provider. (extensions/google/src/gemini-web-search-provider.runtime.ts:276, 0303f3a8f086)Gemini API error: malformed JSON responsewhen the HTTP 200 response is not the expected object/candidates/content/groundingMetadata shape. (extensions/google/src/gemini-web-search-provider.runtime.ts:199, 0303f3a8f086)extensions/google/web-search-provider.test.ts:197, 0303f3a8f086)queryand acceptscount, so a plain{ query, count }call is expected to work rather than fail at response parsing. Public docs:docs/tools/gemini-search.md. (docs/tools/gemini-search.md:82, 0303f3a8f086)git tag --contains 37fbc8cd8fincludesv2026.5.28, so the current Gemini provider parser is present in the same release the reporter tested; no newer local history shows a plain-search parser fix. (37fbc8cd8f94)tools: [{ google_search: {} }]and successful responses containingcandidates,content.parts[].text, andgroundingMetadata.groundingChunks, which matches the parser's intended contract but does not explain the reporter's live malformed body.Likely related people:
extensions/google/src/gemini-web-search-provider.runtime.ts,extensions/google/web-search-provider.test.ts,extensions/google/src/gemini-web-search-provider.ts)src/web-search/runtime.ts,src/agents/tools/web-search-provider-common.ts,extensions/google/src/gemini-web-search-provider.runtime.ts)src/web-search/runtime.ts,extensions/google/src/gemini-web-search-provider.ts,src/agents/tools/web-search-provider-common.ts)extensions/google/src/gemini-web-search-provider.runtime.ts,src/web-search/runtime.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.TarsTriggerBot commentedon Jun 1, 2026
Additional live repro evidence from the original reporter environment:
2026.5.28 (e932160)geminigemini-2.5-flashPOST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent{ "contents": [ { "parts": [ { "text": "current date today" } ] } ], "tools": [ { "google_search": {} } ] }Running through OpenClaw still reproduces:
A direct API call with the same request shape returns HTTP 200 and valid JSON. Sanitized response-shape summary:
{ "status": 200, "contentType": "application/json; charset=UTF-8", "topLevelKeys": [ "candidates", "usageMetadata", "modelVersion", "responseId" ], "candidateCount": 1, "firstCandidateKeys": [ "content", "finishReason", "index", "groundingMetadata" ], "finishReason": "STOP", "contentKeys": [ "parts", "role" ], "partCount": 1, "partKeys": [ "text" ], "textLength": 37, "textPreview": "Today's date is Monday, June 1, 2026.", "hasGroundingMetadata": true, "groundingKeys": [], "groundingChunksCount": 0 }The original longer repro query behaves the same way:
{ "query": "OpenClaw Gemini web search test current date May 31 2026", "status": 200, "candidateCount": 1, "firstCandidateKeys": [ "content", "finishReason", "index", "groundingMetadata" ], "finishReason": "STOP", "partCount": 1, "partKeys": [ "text" ], "textPreview": "The current date is May 31, 2026.", "hasGroundingMetadata": true, "groundingKeys": [], "groundingChunksCount": 0 }Likely failure point:
extensions/google/src/gemini-web-search-provider.runtime.tsappears to allowgroundingMetadata === undefinedby treating it as[], but when Gemini returnsgroundingMetadata: {}withoutgroundingChunks, the provider treats it as malformed.Likely fix direction:
Treat missing/non-array
groundingMetadata.groundingChunksas an empty citation list when text content is present, rather than throwingGemini API error: malformed JSON response.Separate observation:
The CLI also emits this Windows assertion after the provider error:
That may be separate from the Gemini parser bug, but it reproduces after the malformed-response error path.
fix(gemini): accept empty grounding metadata
fix(gemini): accept empty grounding metadata