feat(autogen-ext): add PlasmateFetchTool for lightweight web fetching (10-100x fewer tokens)#7555
Open
dbhurley wants to merge 1 commit intomicrosoft:mainfrom
Open
feat(autogen-ext): add PlasmateFetchTool for lightweight web fetching (10-100x fewer tokens)#7555dbhurley wants to merge 1 commit intomicrosoft:mainfrom
dbhurley wants to merge 1 commit intomicrosoft:mainfrom
Conversation
PlasmateFetchTool fetches a URL using Plasmate (https://github.com/plasmate-labs/plasmate), an open-source Rust browser engine, instead of raw HTTP + HTML or a full headless Chrome. It returns pre-processed content (markdown / text / SOM / links) that is typically 10-100x smaller than raw HTML, directly reducing token cost in agent workflows. This is a lightweight alternative for agents that only need to read pages. For interactive browsing of JavaScript-heavy SPAs, MultimodalWebSurfer remains the right choice. Changes: - python/packages/autogen-ext/src/autogen_ext/tools/plasmate/ - _plasmate_tool.py: PlasmateFetchTool (BaseTool + Component) - Pydantic args schema (url) and config schema (output_format, timeout, selector, extra_headers, fixed_url) - async run() via asyncio.create_subprocess_exec - Component (de)serialisation roundtrip support - output_format: markdown (default), text, som, links - fixed_url to lock the URL at config time - run() returns informative error strings instead of raising (consistent with other tools that handle network failures) - __init__.py: exports PlasmateFetchTool, args, config - python/packages/autogen-ext/tests/tools/plasmate/ - test_plasmate_tool.py: 27 unit tests (init, component roundtrip, cmd building, success paths, error paths, schema validation) - python/packages/autogen-ext/pyproject.toml - Adds plasmate-tool extra: pip install autogen-ext[plasmate-tool]
Contributor
|
@dbhurley please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
MultimodalWebSurferis the right tool when an agent needs to interact with a JavaScript-heavy page through Playwright. But when an agent only needs to read a page — fetch it, summarise it, extract facts — spinning up a full Chromium session is expensive and the raw HTML it returns dwarfs the actual content in token cost.This PR adds
PlasmateFetchTooltoautogen-extas a lightweight read-only complement. It uses Plasmate — an open-source Rust browser engine — to fetch pages and return pre-processed content (markdown / text / structured object model / links) instead of raw HTML.Measured across 45 real sites: 17.7x average compression vs raw HTML, 77x peak. Every token saved before the page reaches the model is a direct cost reduction.
What's in the PR
src/autogen_ext/tools/plasmate/_plasmate_tool.pyPlasmateFetchTool(BaseTool[ArgsModel, str]+Component[Config])src/autogen_ext/tools/plasmate/__init__.pytests/tools/plasmate/test_plasmate_tool.pypyproject.tomlplasmate-tool = ["plasmate>=0.4.1"]The implementation follows the same shape as the existing
HttpTool:_to_config/_from_configasync def run(args, cancellation_token)usingasyncio.create_subprocess_execplasmate-toolextraUsage
Install the extra:
Configuration
output_format"markdown"markdown,text,som(structured JSON),linkstimeout30selectorNone"main")extra_headers{}fixed_urlNoneurlargument is ignored — useful for scoping a tool to a single sourceComparison with existing tools
PlasmateFetchTooldoes not replaceMultimodalWebSurfer— they solve different problems. SPAs that require interaction still need a full browser.PlasmateFetchToolis for the much more common case where the agent just needs to read a static or server-rendered page.Notes
asyncio.create_subprocess_exec(no thread blocking, fully cancellable)run()returns informative error strings instead of raising on network failures, consistent with the agent-friendly pattern used elsewhere in the codebaseChecks