webFetchTool function

AgentTool webFetchTool({
  1. required WebSearchConfig config,
})

Creates the web_fetch tool, sharing WebSearchConfig's HTTP plumbing.

Parameters:

  • url (string, required): absolute http(s) URL of the page to fetch.

Implementation

AgentTool webFetchTool({required WebSearchConfig config}) {
  return AgentTool(
    name: 'web_fetch',
    label: 'web_fetch',
    tier: ApprovalTier.read,
    description:
        'Fetch a web page and return its main content as Markdown: headings, '
        'link anchors, lists, and code blocks are preserved, navigation and '
        'boilerplate are stripped. Known sites (pub.dev) are rendered via '
        'dedicated handlers. Use it to read pages found with web_search.',
    parameters: const {
      'type': 'object',
      'properties': {
        'url': {
          'type': 'string',
          'description': 'The absolute http(s) URL to fetch',
        },
      },
      'required': ['url'],
    },
    execute: (arguments, cancelToken, onUpdate) =>
        _executeWebFetch(config, arguments, cancelToken),
  );
}