⚡ Optimize http_request tool and verify async performance#9
⚡ Optimize http_request tool and verify async performance#9
Conversation
…avior - Refactor `http_request` in `src/matilda_brain/tools/builtins/web.py` to use `_safe_execute_async` for consistent error handling and input sanitization. - Add `scripts/benchmark_http.py` to verify non-blocking behavior (async implementation ~1.2s vs blocking ~30s). - Update `tests/test_tools_builtin.py` to match new error message format from `_safe_execute_async`. - Confirm that `httpx` was already being used, but the refactoring improves code quality and safety. Co-authored-by: mudcube <101564+mudcube@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR ensures that
http_requesttool is fully async and non-blocking, as requested.While the codebase already utilized
httpx, the implementation was refactored to use the_safe_execute_asyncwrapper, aligning it with other tools likeweb_search. This adds standardized input sanitization, timeout management, and error recovery.A benchmark script
scripts/benchmark_http.pywas added to empirically demonstrate the performance difference between a blocking implementation (simulated withurllibto reproduce the issue description) and the current async implementation.Results:
Tests were updated to reflect the standardized error messages.
PR created automatically by Jules for task 5936850271651238139 started by @mudcube