Skip to content

Add CrewAI TinyFish integration#16

Open
pranavjana wants to merge 9 commits into
mainfrom
pranav/crew-ai-sdk-tools
Open

Add CrewAI TinyFish integration#16
pranavjana wants to merge 9 commits into
mainfrom
pranav/crew-ai-sdk-tools

Conversation

@pranavjana
Copy link
Copy Markdown
Collaborator

Summary

  • add the CrewAI TinyFish package under crew-ai/
  • expose SDK-backed tools for web automation, queued runs, run lookup, run listing, search, fetch, and browser session creation
  • depend on tinyfish>=0.2.5 and remove stale batch/cancel tools from the public surface
  • add focused tests and scoped CI

Tests

  • make lint
  • make test
  • python3 -m build

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds a CrewAI integration package that implements TinyFish-backed tools for web automation (sync/async runs, get/list runs, search, fetch, browser sessions), Pydantic input schemas, a shared base tool for client, profile, and proxy handling, unit tests covering SDK interactions and formatting, package metadata and lint config, a Makefile, README, .gitignore entries, and a GitHub Actions CI workflow that runs lint, tests, and a build.

Sequence Diagram

sequenceDiagram
  participant Agent as CrewAI Agent
  participant Tool as TinyfishRun
  participant Base as _TinyfishBaseTool
  participant SDK as TinyFish SDK
  Agent->>Tool: _run(url, goal, browser_profile)
  Tool->>Base: _get_client()
  Base->>Base: check TINYFISH_API_KEY / set TF_API_INTEGRATION
  Base->>SDK: TinyFish(api_key)
  SDK-->>Base: client instance
  Tool->>Base: _run_kwargs(browser_profile, proxy_country)
  Base->>Base: resolve BrowserProfile / proxy_config
  Base-->>Tool: kwargs dict
  Tool->>SDK: client.agent.run(..., **kwargs)
  SDK-->>Tool: RunResult(status, data, error)
  Tool->>Tool: format result (JSON or error string)
  Tool-->>Agent: result string
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main addition: a CrewAI integration for TinyFish web automation tools.
Description check ✅ Passed The description is well-related to the changeset, clearly explaining the package addition, SDK tools exposed, dependencies, and testing approach.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pranav/crew-ai-sdk-tools

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
.github/workflows/crew-ai-ci.yml (1)

35-39: ⚡ Quick win

CI is missing the package build smoke test listed in the PR test plan.

Add python -m build so packaging issues are caught before merge.

🔧 Proposed update
-      - run: python -m pip install -e . -r requirements-dev.txt
+      - run: python -m pip install -e . -r requirements-dev.txt build
@@
       - run: make test
+
+      - run: python -m build
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/crew-ai-ci.yml around lines 35 - 39, Add a packaging smoke
test to the CI steps by inserting a run step that executes "python -m build" (so
packaging errors fail the job) alongside the existing run steps that call
"python -m pip install -e . -r requirements-dev.txt", "make lint", and "make
test"; place the new "python -m build" run immediately after the pip install
step (or before make test) to ensure the project can be built before running
tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crew-ai/pyproject.toml`:
- Around line 6-9: The Python version constraint in requires-python is too low
for the tinyfish dependency; update the requires-python setting (the
requires-python = ">=3.10,<3.14" entry) to a range that includes Python 3.11
(for example raise the lower bound to >=3.11) so that tinyfish>=0.2.5 is
satisfiable; ensure the new upper bound still matches project compatibility
(e.g., ">=3.11,<3.14") and keep the dependency line "tinyfish>=0.2.5" unchanged.

In `@crew-ai/src/tinyfish_web_agent/tool.py`:
- Around line 118-121: The urls Field currently allows any list length but the
schema requires "one to ten URLs"; update the model to enforce this by using
pydantic constraints: either change the annotation to conlist(str, min_items=1,
max_items=10) and keep the Field description, or add min_items=1 and
max_items=10 to the existing Field(...) call for urls so the schema and runtime
validation match (refer to the urls Field definition to locate the change).
- Around line 425-427: The code currently reads runs via runs =
getattr(response, "runs", []) which breaks on tinyfish SDK v0.2.5+ where list
results are in response.data; update the handling in the function that calls
client.runs.list() (look for the variable response and the existing getattr
call) to first check for response.data (e.g., getattr(response, "data", None))
and fall back to response.runs for backward compatibility, and ensure the rest
of the logic uses that resolved list so the function no longer returns "No runs
found" incorrectly.
- Around line 232-236: The code constructs ProxyConfig with
ProxyCountryCode(self.proxy_country) inside _run_kwargs, which evaluates before
_safe_call and raises on invalid country codes; move the ProxyCountryCode
conversion into the try block inside _safe_call so invalid values are caught and
returned as a tool error. Specifically, in the method _run_kwargs, only set
kwargs["proxy_config"] with a placeholder or raw country string, and in the
_safe_call implementation (where exceptions are handled) perform
ProxyCountryCode(self.proxy_country) and then build ProxyConfig(enabled=True,
country_code=ProxyCountryCode(...)); ensure you validate against the allowed
codes (US, GB, CA, DE, FR, JP, AU) or catch ValueError from ProxyCountryCode and
return a controlled tool error instead of letting the exception propagate.

---

Nitpick comments:
In @.github/workflows/crew-ai-ci.yml:
- Around line 35-39: Add a packaging smoke test to the CI steps by inserting a
run step that executes "python -m build" (so packaging errors fail the job)
alongside the existing run steps that call "python -m pip install -e . -r
requirements-dev.txt", "make lint", and "make test"; place the new "python -m
build" run immediately after the pip install step (or before make test) to
ensure the project can be built before running tests.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 243e2ece-a73a-42a9-954e-9192b8b3f907

📥 Commits

Reviewing files that changed from the base of the PR and between 23f22da and 247ac38.

📒 Files selected for processing (9)
  • .github/workflows/crew-ai-ci.yml
  • crew-ai/.gitignore
  • crew-ai/Makefile
  • crew-ai/README.md
  • crew-ai/pyproject.toml
  • crew-ai/requirements-dev.txt
  • crew-ai/src/tinyfish_web_agent/__init__.py
  • crew-ai/src/tinyfish_web_agent/tool.py
  • crew-ai/tests/test_tool.py

Comment thread crew-ai/pyproject.toml Outdated
Comment thread crew-ai/src/tinyfish_web_agent/tool.py Outdated
Comment thread crew-ai/src/tinyfish_web_agent/tool.py Outdated
Comment thread crew-ai/src/tinyfish_web_agent/tool.py Outdated
Adds the CrewAI TinyFish package with SDK-backed tools for web automation, queued runs, run lookup, run listing, web search, content fetch, and browser session creation. Uses tinyfish>=0.2.5, includes focused tests, and adds scoped CI.
Align Python requirements with TinyFish SDK, enforce fetch URL bounds, handle invalid proxy countries, support SDK data responses, and add CI build coverage.
@pranavjana pranavjana force-pushed the pranav/crew-ai-sdk-tools branch from 9509c8d to 5f69c59 Compare May 14, 2026 12:04
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
crew-ai/src/tinyfish_web_agent/tool.py (1)

214-214: 💤 Low value

Consider using PrivateAttr for clarity with cached client.

In Pydantic V2, while underscore-prefixed attributes are automatically treated as private (excluded from fields and serialization), explicitly using PrivateAttr makes this intent clear and is considered best practice.

♻️ Suggested fix
+from pydantic import PrivateAttr
 
 class _TinyfishBaseTool(BaseTool):
     ...
     api_key: Optional[str] = None
     proxy_country: Optional[str] = None
 
-    # Cached per-instance to avoid re-creating on every call.
-    _client: Optional[TinyFish] = None
+    # Cached per-instance to avoid re-creating on every call.
+    _client: Optional[TinyFish] = PrivateAttr(default=None)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crew-ai/src/tinyfish_web_agent/tool.py` at line 214, Replace the
underscore-prefixed cached client attribute with an explicit Pydantic
PrivateAttr: import PrivateAttr from pydantic and change the declaration for
_client (currently "_client: Optional[TinyFish] = None") to use PrivateAttr
(e.g. "_client: Optional[TinyFish] = PrivateAttr(default=None)" or "_client =
PrivateAttr(default=None)") so the cached TinyFish client is clearly marked
private and excluded from model fields/serialization; update imports
accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crew-ai/src/tinyfish_web_agent/tool.py`:
- Line 214: Replace the underscore-prefixed cached client attribute with an
explicit Pydantic PrivateAttr: import PrivateAttr from pydantic and change the
declaration for _client (currently "_client: Optional[TinyFish] = None") to use
PrivateAttr (e.g. "_client: Optional[TinyFish] = PrivateAttr(default=None)" or
"_client = PrivateAttr(default=None)") so the cached TinyFish client is clearly
marked private and excluded from model fields/serialization; update imports
accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 479bb39f-692b-4563-a155-b9e37ea166b3

📥 Commits

Reviewing files that changed from the base of the PR and between 56710dd and fdefd95.

📒 Files selected for processing (5)
  • .gitignore
  • crew-ai/pyproject.toml
  • crew-ai/src/tinyfish_web_agent/__init__.py
  • crew-ai/src/tinyfish_web_agent/tool.py
  • crew-ai/tests/test_tool.py
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
🚧 Files skipped from review as they are similar to previous changes (3)
  • crew-ai/pyproject.toml
  • crew-ai/src/tinyfish_web_agent/init.py
  • crew-ai/tests/test_tool.py

Drops the multi-tool SDK-backed design (which failed to install in Crew
Studio sandboxes) in favour of one focused tool that hits the TinyFish
agent endpoint via raw requests:

* One BaseTool: TinyfishWebAgent (sync run on /v1/automation/run)
* Drops tinyfish SDK dep; only requires crewai[tools] and requests
* Lowers requires-python to >=3.10,<3.14 (matches CrewAI's broader floor)

The class name matches CamelCase(package_name), so Crew Studio's
auto-import resolves it correctly and exposes a single card to users.
Code-first users can also import it directly. Tests mock requests.post
instead of the SDK client.
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.

1 participant