Skip to content

Implement size checks for web content retrieval #35

Description

@codegen-sh

Problem

The current implementation of web content retrieval doesn't check the size of webpages before processing them. This can lead to memory issues, slow responses, or crashes when users ask the bot to process very large websites.

Proposed Solution

Add a mechanism to check the size of a webpage before fully processing it:

  1. Use HTTP HEAD requests to check the Content-Length header before downloading the full content
  2. Implement a configurable maximum size limit for web content (e.g., 10MB by default)
  3. Return a clear error message when content exceeds the size limit

Implementation Details

  • Add a new configuration option MAX_WEB_CONTENT_SIZE_MB (default: 10)
  • Modify the get_website_content tool and answer_webcontent method to check content size
  • Add a specific error message for oversized content
  • Update error handling to provide better feedback to users

Expected Outcome

  • The bot will avoid processing excessively large web content
  • Users will receive clear feedback when content is too large
  • The application will be more stable and less prone to memory issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions