feat(py): add web_fetch vended tool - #4001
Conversation
|
@strandly-the-agent Review this PR. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
@strandly-the-agent Review this PR. |
Re-review (following commit
|
Re-review (following commit
|
Re-review (following amend
|
| result = await summarizer.invoke_async( | ||
| f"Fetched URL: {url}\n\nRequest: {prompt}\n\n--- Content ---\n{content}" | ||
| ) | ||
| return str(result) |
There was a problem hiding this comment.
Issue (Important, non-blocking): the full fetched content — up to max_bytes (5 MiB by default) — is injected verbatim into the summarizer prompt with no truncation. For large pages this can overflow the model's context window or cause large, surprising token costs, and it'll surface as an opaque model error rather than the tidy ValueError/TimeoutError the fetch path produces.
Suggestion: bound the content handed to the summarizer (e.g. a char/token budget with a clear "content truncated" marker), and/or wrap invoke_async failures into the tool's ValueError so summarizer errors are reported consistently with fetch errors.
| ) | ||
| result = await summarizer.invoke_async( | ||
| f"Fetched URL: {url}\n\nRequest: {prompt}\n\n--- Content ---\n{content}" | ||
| ) |
There was a problem hiding this comment.
Issue (Important, non-blocking): the summarizer Agent is created fresh here and isn't connected to the host agent's cancel signal, so if the host is cancelled while this invoke_async LLM call is in flight, it won't abort. That's the most expensive operation in the whole tool, and it's currently the least cancellable — the fetch at least checks the signal (pre-flight), but the summarize step checks nothing.
Suggestion: propagate the host's _cancel_signal into the summarizer (or race the invoke_async coroutine against the cancel event and aclose/cancel on set), so cancellation behaves consistently across both phases.
Re-review (following commit
|
Re-review (following commit
|
Re-review (force-push
|
| provided by the operator, giving full control over transport configuration, | ||
| caching, proxies, redirects, and connection pooling. | ||
|
|
||
| When ``prompt`` is non-empty, a summarizer agent answers the prompt over the |
There was a problem hiding this comment.
To the reviewer: what are your thoughts on DevX like this make_web_fetch(extractor="agentic | markdown") if web_fetch is doing too much right now? Stan has a use for the question/answer fetching and will likely be a consumer for this tool.
Description
Adds web_fetch as a vended tool to the Python SDK. This implements the markdown conversion feature from the http_request tool in the tools repo. Combined with the http_request tool port, the web_fetch tool enables us to deprecate the tool repo's http_request. This PR combines the original web_fetch implementation and the Stan implementation.
ContextOffloader.beautifulsoup4andmarkdownifyare new dependencies handling HTML to markdown conversion because of their light weight and prior usage in the tools repo.turndownwill likely be used in the TS implementation, since it is already used in the site docs. While the markdown engines will be different, this tradeoff is acceptable because the model simply needs the page rendered in markdown without hard formatting requirements.musllinuxand Windows ARM. It is also much heavier at 7 MB, compared tobeautifulsoup4andmarkdownify(125 kB)Public API
Default web_fetch tool
Custom configuration
Related Issues
Closes #3239 on the Python side. TS implementation will be a follow-up.
Documentation PR
Documentation added in
site/src/content/docs/user-guide/concepts/tools/vended-tools.mdx.Type of Change
New feature
Testing
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.