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:
- Use HTTP HEAD requests to check the Content-Length header before downloading the full content
- Implement a configurable maximum size limit for web content (e.g., 10MB by default)
- 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
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:
Implementation Details
MAX_WEB_CONTENT_SIZE_MB(default: 10)get_website_contenttool andanswer_webcontentmethod to check content sizeExpected Outcome