Skip to content

Feat: Strands core Apify tools#1

Open
daveomri wants to merge 20 commits intomainfrom
feat/strands-core-apify-tools
Open

Feat: Strands core Apify tools#1
daveomri wants to merge 20 commits intomainfrom
feat/strands-core-apify-tools

Conversation

@daveomri
Copy link
Copy Markdown
Collaborator

@daveomri daveomri commented Apr 1, 2026

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 ApifyToolClient helper 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_TOKEN to be set in the environment. The apify-client SDK is added as an optional dependency (pip install strands-agents-tools[apify]).

Files Changed

File Change
src/strands_tools/apify.py New tool module with 6 @tool-decorated functions and ApifyToolClient helper
tests/test_apify.py Comprehensive unit tests (30+ test cases)
docs/apify_tool.md Tool documentation page
pyproject.toml apify optional dependency group (apify-client>=2.5.0,<3.0.0), added to static-analysis and test env features
README.md Tool table entries, usage examples, and environment variable documentation

Related Issues

#2
#3

Documentation PR

apify/docs#1

Type of Change

New Tool

Testing

  • Added comprehensive unit tests in tests/test_apify.py covering all six tools, including:

    • Success paths for Actor runs, task runs, dataset retrieval, and URL scraping
    • Error handling (failed runs, timed-out runs, API exceptions)
    • ApifyApiError mapping (401 auth, 404 not found, 429 rate limit)
    • Missing token validation for every tool entry point
    • Missing dependency (apify-client not installed) fallback for every tool
    • Pagination parameter forwarding
    • URL validation (invalid scheme, missing scheme)
    • Task-specific edge cases (None response from TaskClient.call(), input omission when not provided)
  • Ran hatch run prepare locally to verify no warnings or lint issues.

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

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:

Original Fixed Rule
"Actor and Task ecosystem" "Actor and task ecosystem" "task" is lowercase
"default Dataset results" (2x) "default dataset results" "dataset" is lowercase
"a saved Apify Task" "a saved Apify task" "task" is lowercase
"runs a Task and fetches" "runs a task and fetches" "task" is lowercase
"Apify Dataset by ID" "Apify dataset by ID" "dataset" is lowercase
"the Apify Website Content Crawler" "the Website Content Crawler Actor" Actor name doesn't need "Apify" prefix; "the" OK when modifying a noun
"Actor runs, Task runs" "Actor runs, task runs" "task" is lowercase

Copy link
Copy Markdown

@jirispilka jirispilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jirispilka
Copy link
Copy Markdown

@daveomri Thanks for handling all the changes.
I was not able to resolve the comments. I reviewed it and I think we are good to go!

@drobnikj drobnikj requested review from drobnikj and removed request for drobnikj April 7, 2026 11:21
@drobnikj
Copy link
Copy Markdown
Member

drobnikj commented Apr 7, 2026

One thing the PR got me thinking about: should we also add an apify_search_actors tool for Actor discovery?

Yes, makes sense, let's add it. It could use Actor store search ATM.

Copy link
Copy Markdown
Member

@drobnikj drobnikj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants