Class: Tools::WebGet

Inherits:
Base
  • Object
show all
Defined in:
lib/tools/web_get.rb

Overview

Fetches content from a URL via HTTP GET. Returns a structured result with the response body and Content-Type header so that ToolDecorator can apply format-specific conversion (HTML → Markdown, JSON → TOON, etc.).

The body is truncated to Anima::Settings.max_web_response_bytes before decoration to cap memory usage on large responses.

Only http and https schemes are allowed.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, schema, truncation_threshold

Constructor Details

This class inherits a constructor from Tools::Base

Class Method Details

.descriptionObject



18
# File 'lib/tools/web_get.rb', line 18

def self.description = "Fetch a URL."

.input_schemaObject



20
21
22
23
24
25
26
27
28
# File 'lib/tools/web_get.rb', line 20

def self.input_schema
  {
    type: "object",
    properties: {
      url: {type: "string"}
    },
    required: ["url"]
  }
end

.tool_nameObject



16
# File 'lib/tools/web_get.rb', line 16

def self.tool_name = "web_get"

Instance Method Details

#execute(input) ⇒ Hash

Parameters:

  • input (Hash<String, Object>)

    string-keyed hash from the Anthropic API. Supports optional “timeout” key (seconds) to override the global web_request_timeout setting.

Returns:

  • (Hash)

    ‘String, content_type: String` on success

  • (Hash)

    ‘String` on failure



35
36
37
# File 'lib/tools/web_get.rb', line 35

def execute(input)
  validate_and_fetch(input["url"].to_s, timeout: input["timeout"])
end