Conversation
Made-with: Cursor
jirispilka
left a comment
There was a problem hiding this comment.
Great work on this PR! 👏🏻
Really happy with this. After long time, I got a chance to read python code (and the code is great).
Left a few comments.
I also opened a small follow-up PR that injects Apify context into the docstrings - what an Actor is, what a dataset is, etc. This is something we've overlooked in the past, but since LLMs select tools automatically, good descriptions will matter more and more.
One thing the PR got me thinking about: should we also add an apify_search_actors tool for Actor discovery?
That way the agent could find the right Actor for a task rather than requiring the user to know the actor ID upfront
@drobnikj what do you think?
I don't see any major issues so pre-approving but lets us discuss the open question before merging.
|
@daveomri Thanks for handling all the changes. |
Yes, makes sense, let's add it. It could use Actor store search ATM. |
Tester guides
link
Apify docs
link
Description
This PR adds Apify platform integration as a new tool for Strands Agents (
src/strands_tools/apify.py), enabling agents to interact with the Apify Actor and task ecosystem for web scraping and automation tasks.Six new tools are introduced:
Actor Execution:
apify_run_actor: Run any Apify Actor by ID with arbitrary input and return run metadata (run ID, status, dataset ID, timestamps).apify_run_actor_and_get_dataset: Convenience tool that runs an Actor and fetches its default dataset results in a single call.Task Execution:
apify_run_task: Run a saved Apify task by ID with optional input overrides and return run metadata. Tasks are pre-configured Actor setups that can be rerun without redefining inputs.apify_run_task_and_get_dataset: Convenience tool that runs a task and fetches its default dataset results in a single call.Data Retrieval:
apify_get_dataset_items: Fetch items from an existing Apify dataset by ID, with pagination support.apify_scrape_url: Scrape a single URL using the Website Content Crawler Actor and return the page content as markdown.All tools share a common
ApifyToolClienthelper class, consistent error handling (with user-friendly messages for 401/404/429 API errors), URL validation, dependency checking, and Rich console output.All tools require
APIFY_API_TOKENto be set in the environment. Theapify-clientSDK is added as an optional dependency (pip install strands-agents-tools[apify]).Files Changed
src/strands_tools/apify.py@tool-decorated functions andApifyToolClienthelpertests/test_apify.pydocs/apify_tool.mdpyproject.tomlapifyoptional dependency group (apify-client>=2.5.0,<3.0.0), added to static-analysis and test env featuresREADME.mdRelated Issues
#2
#3
Documentation PR
apify/docs#1
Type of Change
New Tool
Testing
Added comprehensive unit tests in
tests/test_apify.pycovering all six tools, including:apify-clientnot installed) fallback for every toolTaskClient.call(), input omission when not provided)Ran
hatch run preparelocally to verify no warnings or lint issues.I ran
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.
Changes made to the PR description: