Skip to content

feat(tools): add generic search tool - #2140

Merged
waleedlatif1 merged 1 commit into
stagingfrom
feat/search
Nov 30, 2025
Merged

feat(tools): add generic search tool#2140
waleedlatif1 merged 1 commit into
stagingfrom
feat/search

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • add generic search tool

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercelBot commented Nov 30, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
docsReadyReadyPreviewCommentNov 30, 2025 10:15pm

@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Adds a generic web search tool powered by Exa AI that charges $0.01 per search query.

Key Changes

  • New search_tool with proper authentication, validation, and error handling
  • API route at /api/tools/search that wraps the existing exa_search tool
  • Search block configuration with icon, inputs/outputs for workflow integration
  • Universal cost extraction in generic-handler.ts - now extracts cost info from all tools (not just knowledge tools)
  • Test improvements using vi.hoisted() for proper mock initialization order
  • Complete documentation and icon updates

Implementation Notes

The search tool wraps the existing exa_search tool rather than implementing a new search integration, which is a sensible approach for code reuse. The fixed $0.01 cost is applied at the API layer regardless of the number of results returned.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation follows established patterns in the codebase, includes proper error handling and authentication, has comprehensive tests, and the refactoring to universal cost extraction is well-tested and backward compatible
  • No files require special attention

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/tools/search/tool.ts5/5Adds new search tool configuration with proper parameter validation and response handling
apps/sim/app/api/tools/search/route.ts4/5API route handler for search with authentication, validation, and error handling; calls underlying exa_search tool
apps/sim/blocks/blocks/search.ts5/5Block configuration for search with proper icon, inputs, outputs, and tool access
apps/sim/executor/handlers/generic/generic-handler.ts5/5Refactored to extract cost info from all tools, not just knowledge tools - universal cost tracking
apps/sim/lib/billing/constants.ts5/5Added SEARCH_TOOL_COST constant set to $0.01

Sequence Diagram

sequenceDiagram
participant User
participant SearchBlock
participant SearchRoute as /api/tools/search
participant AuthCheck as Authentication
participant ToolExecutor as executeTool
participant ExternalAPI as External Search API
User->>SearchBlock: Trigger search with query
SearchBlock->>SearchRoute: POST request with query & num
Note over SearchRoute: Validate request schema
SearchRoute->>AuthCheck: Verify user authentication
AuthCheck-->>SearchRoute: Return userId and authType
SearchRoute->>SearchRoute: Check environment configuration
alt Configuration missing
SearchRoute-->>SearchBlock: 503 Service not configured
end
SearchRoute->>ToolExecutor: Execute exa_search tool
ToolExecutor->>ExternalAPI: Send search request
ExternalAPI-->>ToolExecutor: Return search results
ToolExecutor-->>SearchRoute: Formatted results
SearchRoute->>SearchRoute: Transform & add cost info
SearchRoute-->>SearchBlock: Success with results and cost
SearchBlock-->>User: Display search results
Loading

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

16 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
waleedlatif1 merged commit e3a57d3 into stagingNov 30, 2025
4 of 5 checks passed
@waleedlatif1
waleedlatif1 deleted the feat/search branch November 30, 2025 22:13
waleedlatif1 added a commit that referenced this pull request Dec 1, 2025
… sendgrid, linkedin, more tools (#2148)
* feat(tools): added smtp, sendgrid, mailgun, linkedin, fixed permissions in context menu (#2133)
* feat(tools): added twilio sendgrid integration
* feat(tools): added smtp, sendgrid, mailgun, fixed permissions in context menu
* added top level mocks for sporadically failing tests
* incr type safety
* fix(team-plans): track departed member usage so value not lost (#2118)
* fix(team-plans): track departed member usage so value not lost
* reset usage to 0 when they leave team
* prep merge with stagig
* regen migrations
* fix org invite + ws selection'
---------
Co-authored-by: Waleed <walif6@gmail.com>
* feat(i18n): update translations (#2134)
Co-authored-by: waleedlatif1 <waleedlatif1@users.noreply.github.com>
* feat(creators): add verification for creators (#2135)
* feat(tools): added apify block/tools (#2136)
* feat(tools): added apify
* cleanup
* feat(i18n): update translations (#2137)
Co-authored-by: waleedlatif1 <waleedlatif1@users.noreply.github.com>
* feat(env): added more optional env var examples (#2138)
* feat(statuspage): added statuspage, updated list of tools in footer, renamed routes (#2139)
* feat(statuspage): added statuspage, updated list of tools in footer, renamed routes
* ack PR comments
* feat(tools): add generic search tool (#2140)
* feat(i18n): update translations (#2141)
* fix(sdks): bump sdk versions (#2142)
* fix(webhooks): count test webhooks towards usage limit (#2143)
* fix(bill): add requestId to webhook processing (#2144)
* improvement(subflow): remove all associated edges when moving a block into a subflow (#2145)
* improvement(subflow): remove all associated edges when moving a block into a subflow
* ack PR comments
* fix(polling): mark webhook failed on webhook trigger errors (#2146)
* fix(deps): declare core transient deps explicitly (#2147)
* fix(deps): declare core transient deps explicitly
* ack PR comments
---------
Co-authored-by: Vikhyath Mondreti <vikhyathvikku@gmail.com>
Co-authored-by: waleedlatif1 <waleedlatif1@users.noreply.github.com>
Sign up for freeto 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

@waleedlatif1