sgl-project/sglang · error · ValueError
browser.find requires a pattern
Error message
browser.find requires a pattern
What it means
SGLang's browser tool dispatch rejects a browser.find action whose arguments lack a truthy 'pattern' field. browser.find searches previously loaded page text for a regex/substring and cannot proceed without a pattern.
Source
Thrown at python/sglang/srt/entrypoints/tool.py:84
async def _dispatch_browser_call(
self, context: "ConversationContext", recipient: str, args: dict[str, Any]
) -> str:
if recipient == "browser.search":
query = args.get("query")
if not query:
raise ValueError("browser.search requires a query")
data = await self.exa_client.search(query)
return self._format_search_results(context, query, data)
if recipient == "browser.open":
url = self._resolve_url(context, args)
data = await self.exa_client.contents([url])
return self._format_page_contents(context, url, data)
if recipient == "browser.find":
pattern = args.get("pattern")
if not pattern:
raise ValueError("browser.find requires a pattern")
return await self._find_pattern(context, args, pattern)
raise ValueError(f"Unknown browser action: {recipient}")
def _browser_state(self, context: "ConversationContext") -> dict[str, Any]:
state = getattr(context, "_sglang_exa_browser_state", None)
if state is None:
state = {"pages": {}, "page_text": {}}
setattr(context, "_sglang_exa_browser_state", state)
return state
def _format_search_results(
self, context: "ConversationContext", query: str, data: dict[str, Any]
) -> str:
state = self._browser_state(context)
state["pages"] = {}
state["page_text"] = {}
View on GitHub (pinned to 0132848349)
Solutions
- Include a non-empty "pattern" string in browser.find arguments
- Validate args['pattern'] before dispatch and re-ask the model if missing
- Update the tool schema to mark pattern as required
Example fix
# before
args = {"cursor": "0"}
# after
args = {"cursor": "0", "pattern": "pricing"} Defensive patterns
Strategy: validation
Validate before calling
if not args.get("pattern"):
raise ValueError("browser.find requires a pattern") Type guard
def valid_find_args(args: dict) -> bool:
return isinstance(args.get("pattern"), str) and bool(args["pattern"].strip()) Try / catch
try:
out = await tool._dispatch_browser_call(context, "browser.find", args)
except ValueError as e:
if "requires a pattern" in str(e):
# surface to the model for correction
... Prevention
- Mark 'pattern' as required in the tool schema exposed to the model
- Validate args dict keys before dispatch
When it happens
Trigger: Dispatching recipient 'browser.find' with args missing 'pattern', or with an empty/null pattern, e.g. {"cursor": "0"} only.
Common situations: Model emitting browser.find with only a cursor argument and forgetting the pattern, or schema mismatch after changing the tool definition.
Related errors
- browser.search requires a query
- browser.open requires a cursor or url
- No browser tool call found
- Unknown browser action: {recipient}
- Unknown browser cursor: {cursor}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/1a8bb470a2fc8d0a.
Report an issue: GitHub.