jumpserver/jumpserver · error · AgentLimitError
Maximum web search count exceeded.
Error message
Maximum web search count exceeded.
What it means
Raised by the agent runner's stream loop when the model attempts more web search tool calls than allowed by max_web_search_calls. It is a hard safety limit that aborts the run to bound cost and latency. Duplicate identical searches are blocked separately before this check.
Source
Thrown at apps/chat_ai/agents/runner.py:705
if not query:
messages.append(self._tool_message(
tool_call,
{'error': 'The original user question cannot form a public web query.'},
))
continue
signature = json.dumps(
{'tool': name, 'query': query},
sort_keys=True,
ensure_ascii=False,
)
if signature in web_search_signatures:
messages.append(self._tool_message(
tool_call, {'error': 'Duplicate web search was blocked.'}
))
continue
web_search_signatures.add(signature)
if web_search_count >= self.max_web_search_calls:
raise AgentLimitError('Maximum web search count exceeded.')
web_search_count += 1
yield sse_event('web_search_start', {'query': query, 'action': action})
try:
result = await web_search.search(query, self.agent_run)
except WebSearchError as exc:
error = sanitize_text(str(exc))[:512]
yield sse_event('web_search_result', {
'query': query,
'action': action,
'ok': False,
'error': error,
'sources': [],
})
messages.append(self._tool_message(tool_call, {'error': error}))
continue
sources = [
{'title': item['title'], 'url': item['url']}
for item in result['results']View on GitHub (pinned to 6ec464fabd)
Solutions
- Increase max_web_search_calls for the agent/profile configuration.
- Tighten the agent system prompt so it batches or limits searches per step.
- Cache or improve search result quality so the model stops re-querying.
- Catch AgentLimitError in the consumer and surface a friendly 'search limit reached' message.
Example fix
# before runner = AgentRunner(..., max_web_search_calls=2) # after runner = AgentRunner(..., max_web_search_calls=8)
Defensive patterns
Strategy: validation
Validate before calling
if agent_run.web_search_count >= runner.max_web_search_calls:
raise UserError('Web search limit reached; narrow your question.') Type guard
def web_search_budget_left(runner) -> bool:
return runner.web_search_count < runner.max_web_search_calls Try / catch
try:
async for event in runner.stream(...):
...
except AgentLimitError as exc:
if 'web search' in str(exc):
yield sse_event('error', {'message': 'Web search limit reached.'}) Prevention
- Set max_web_search_calls proportional to task complexity.
- Prompt the model to plan queries before searching.
- Log search counts per run to tune the limit.
When it happens
Trigger: POST to the conversation stream endpoint (stream_message/regenerate/branch/background) and the assistant issues more distinct web_search tool calls than the configured max_web_search_calls within a single agent run.
Common situations: Low max_web_search_calls setting combined with an agent prompt that encourages broad research; long multi-step tasks where the model keeps issuing new queries; a search tool returning poor results causing the model to retry with different queries.
Related errors
- Maximum Core API call count exceeded.
- Maximum agent step count exceeded.
- Assistant is not available for this operation.
- core_api_failed
- You do not have permission to use this Chat AI assistant.
AI-assisted analysis of jumpserver/jumpserver@6ec464fabd (2026-08-28).
Data as JSON: /api/errors/944c23ebd35d8f51.
Report an issue: GitHub.